cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Portals Javascript Changes you made may not be saved

$(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

1 ACCEPTED SOLUTION

Accepted Solutions
Responsive Resident
Responsive Resident

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.

View solution in original post

7 REPLIES 7
Super User
Super User

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 

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

Super User
Super User

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.

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

Super User
Super User

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.

Responsive Resident
Responsive Resident

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.

View solution in original post

Frequent Visitor

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

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Users online (21,181)