A little issue with a field

Good afternoon,


I'm asking here again because I have a little problem. I will try to explain it in the best way.

I've done some custom content scripts ("Script de contenido personalizado"):

var o = $('input[name="_HIDDENcon_terminal"]').val();
Terminal(o);

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

function Terminal(tipo){
var term=tipo;
if((tipo=="undefined")||(tipo=="")) term = $('#con_terminal option:selected').val();
var array=["producto", "imei"];
if(term=='No'){
for (var i in array){
$("#_Captcon_" + array[i]).hide();
$("#_Datacon_" + array[i]).hide();
}
}
else{
for (var i in array){
$("#_Captcon_" + array[i]).show();
$("#_Datacon_" + array[i]).show();
}
}
}

These code hides two fields (with its captions) depending on the answer of a 3rd field. When I select "No" on field "Terminal", in a first moment I see it like this:

When I want to edit it, it looks like this:

In theory, I must not be able to see the advanced search box at right. But, when I answer "Yes", and then I also answer "No", it looks like this:

The fields that I want to hide hide.

I also have this code on creation scripts for "producto" and "imei":

Terminal = Values('con_terminal');
Required = false;

if (Terminal == 'si'){

Required = true;

}

And this one on modification script in "Terminal":

Terminal(this.value);

Is there something wrong in my code?

My CRM version is 7.1 SP2.

Thanks in advance

  • 0

    Hi,

    If I read you right, are you saying that the code works ok when you select Yes, then No, and it's only when you hit the Edit button for the first time that it doesn't work? Are you calling your script as an onload event to make sure that everything's loaded before you call your stuff? Seeing as you're using jQuery, you can do this using $(document).ready();

    Alternatively, you might try using console.log() to write out debugging information to the browser's developer console.

    I wouldn't set the Required value using a Create script, since a user might change the value for Terminal to No. You're better off checking for that with a Validate script.

    Thanks,

    Rob

  • 0

    Hi Rob,

    Yes, my Script is called into a $(document).ready(); function, so, I understand it should be working... but it isn't doing it at all...

    Thanks for your advice about Required value!

    I'm going to try to do the console.log to get some data...

    We keep in touch, thank you so much!!

  • 0

    Hi again Rob,

    I've been testing it with the console.log() method and in theory it works properly... but only in theory.

    The field keeps on non-hiding when hitting Edit button for the first time...