web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Portals Javascript Cha...
Power Pages
Unanswered

Portals Javascript Changes you made may not be saved

(0) ShareShare
ReportReport
Posted on by 12

$(document).ready(function() {
$("#new_registrobool").change(onGuia);
$("#new_registrobool").change();

});

function onGuia(){
var valor = $("#new_registrobool").val();

if (valor == 100000002 )
{

$("#new_cantidadmaximadeparticipantesnum").closest("td").hide();
$("#new_cantidadmaximadeparticipantesnum").closest("td").hide();

$("#new_modalidadvirtualbool").closest("td").hide();
$("#new_presenciadeadulto").closest("td").hide();
$("#new_especifiquematerialesmtxt").closest("td").hide();
$("#new_objetivotxt").closest("td").hide();
$("#new_presenciadeadulto").closest("td").hide();
$("#new_modalidadvirtualbool").closest("td").hide();
$("#new_aclaracionescomentariosmtxt").closest("td").hide();
$("#new_minutosdeduracionnum").closest("td").hide();



}

}

 

Anyone know why?

 

Thx

Categories:
I have the same question (0)
  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Dbotta , 

     

    Can you please tell us the scenario more specifically like where you have written this script ? Entity form / Web pages or in web files ? We can assist you more once we get clarity. Thanks 

  • Diego Botta Profile Picture
    12 on at

    Sorry, the translator omitted my introduction. I am using Portal and I am located in a form of the entity. The javascript I add it through the button that is shown in the interface and then options. 

    I don't know why without having made any changes it suggests that I will lose the changes when I exit. This only happens when javascript is in place (and does its job of hiding fields). The field that evaluates to trigger the action is a pick list

    JS.JPG

  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Dbotta , 

     

    I have tested it using your same approach and it works fine. I believe it is not taking the changes due to Portal Language is different in your case. 

     

    To add your script  can you please try this approach using Portal management 

     

    1. Under content > Web pages  > Choose your web page (in this case Home page) 

    2.  Scroll down until you see Localized content > and then click the page again  

    3. Click Advanced and then under custom javascript section you can add your jQuery. 

     

    ragavanrajan_0-1611177905355.png

     

    4. Click Save and close 

    5. Now in your portal studio  > Please press the sync configuration and browse website. 

     

    Tip: In your jQuery add the console log to see your logging once you followed the above approach. 

    Hope it helps. 

    ------------

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Diego Botta Profile Picture
    12 on at

    thanks @ragavanrajan ,

     

    I checked where you say and the JS is working but it keeps insisting that I made some record change when I haven't and pop up a message if I want to cancel the action or I will lose everything. without javascript this does not happen

     

    js3.PNGjs2.PNG

  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Dbotta ,

     

     May be try this approach instead of jQuery sometimes vanilla javascript works better.  I can see that you are trying to hide fields based on if certain condition is met. Your change detection in jQuery is making that popup. 

     

    This is a sample vanilla JavaScript. Please alter it according to your use.

     

     console.log("hiding fields");
     document.getElementById("new_modalidadvirtualbool").style.display = 'none';

    This is tested and working for me very well. 

     

    Give a try and hope it will solve your problem. 

     

    ------------

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    Fubar Profile Picture
    8,338 Super User 2025 Season 2 on at

    Usually the change detection for the Portal is based on a isdirty flag that is set when you change field values, but you may find that your code is triggering this via your .change() in the document.ready function.  Rather than triggering change() you should be able to just call onGuia() from that code snippet.

  • Diego Botta Profile Picture
    12 on at

    Many thanks to both of you for sharing your solutions with me. We have achieved it. I still have a lot to learn.

  • Isr Profile Picture
    3 on at

    This helped. Thanks a lot.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard