Hello,
Can somebody please tell me what is wrong with this code?
I`m trying to hide the field "Tip_x0020_Sistem_x0020_Rapid" until the Value of the field "Title" equals some TEXT, in this example the text is "Test".
And to be more precise I am trying to show/hide a couple of fields based on a Drop Down Lookup field`s values.
fd.spRendered(function() {
function hideOrShowField() {
if (fd.field('Title').value == ('1')) {
// Show the field
fd.field('Tip_x0020_Sistem_x0020_Rapid').show();
} else {
// Hide the field
fd.field('Tip_x0020_Sistem_x0020_Rapid').hide();
}
}
// Calling hideOrShowField when the user changes the Start Date
fd.field('Title').$on('change',hideOrShowField);
// Calling hideOrShowField on form loading
hideOrShowField();
});
Thank you!
Hello @Vasilii_Burca,
You need to remove extra braces:
fd.field('Title').value == '1'
And to know how to work with the lookup field please see the documentation.
Followed your instructions and sill no light at the end of the tunnel (.
fd.spRendered(function() {
function hideTip_x0020_Sistem_x0020_Rapid() {
if fd.field('Product').value.LookupValue == 'ParolÄ uitatÄ' {
// Show the Tip_x0020_Sistem_x0020_Rapid field
fd.field('Tip_x0020_Sistem_x0020_Rapid').show();
} else {
// Hide the Tip_x0020_Sistem_x0020_Rapid field
fd.field('Tip_x0020_Sistem_x0020_Rapid').hide();
}
}
// Calling hideTip_x0020_Sistem_x0020_Rapid when the user changes Product Field
fd.field('Product').$on('change',hideTip_x0020_Sistem_x0020_Rapid);
// Calling hideTip_x0020_Sistem_x0020_Rapid on form loading
hideTip_x0020_Sistem_x0020_Rapid();
});
The screen of error and form
Thank you!
Hello @Vasilii_Burca,
You needed to remove extra braces around the value, but to keep them around the condition.
I've updated your code, please see below.
fd.spRendered(function() {
function hideTip_x0020_Sistem_x0020_Rapid() {
if (fd.field('Product').value.LookupValue == 'ParolÄ uitatÄ') {
// Show the Tip_x0020_Sistem_x0020_Rapid field
fd.field('Tip_x0020_Sistem_x0020_Rapid').show();
} else {
// Hide the Tip_x0020_Sistem_x0020_Rapid field
fd.field('Tip_x0020_Sistem_x0020_Rapid').hide();
}
}
// Calling hideTip_x0020_Sistem_x0020_Rapid when the user changes Product Field
fd.field('Product').$on('change',hideTip_x0020_Sistem_x0020_Rapid);
// Calling hideTip_x0020_Sistem_x0020_Rapid on form loading
hideTip_x0020_Sistem_x0020_Rapid();
});
Thank you @mnikitina it worked as usual !!!
1 Like