Hide and make visible a field on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 01:32 AM
Hi,
I need to hide a field 'Reason for updating expected remediation date' on form when it loads.
for this i wrote this onload script
g_form.setVisible('u_reason_for_updated_remediation_date', false);
this is working fine.
and there is another field 'Expected remediation date' which will take value for the first time. but later if the date is updated, then this 'reason' field should be visible and should be mandatory. for this i wrote onchange script
if (oldValue != newValue){
g_form.setVisible('u_reason_for_updated_remediation_date', true);
g_form.setMandatory('u_reason_for_updated_remediation_date', true);
}
but this is not working as expected it is visible and mandatory when first time date field is being filled. i don't want this, i want if second time the date field is being updated that time 'reason' field should be visible.
For this i tried this script also, still not working.
var previousValue = g_form.getValue('u_expected_remediation_date');
{
if(previousValue != null && previousValue != newValue) {
g_form.setVisible('u_reason_for_updated_remediation_date', true);
g_form.setMandatory('u_reason_for_updated_remediation_date', true);
}
Please suggest.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 01:37 AM
You can use- g_form.isNewRecord()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 01:47 AM
Hi,
You can try this, if again filed then u want to make field mandatory.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || oldValue=='') {
return;
}
g_form.setVisible('u_reason_for_updated_remediation_date', true);
g_form.setMandatory('u_reason_for_updated_remediation_date', true);
}
Hope it helps,
Thanks,
Apurva Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 02:04 AM
Hi Arohi,
remove the brace like se as below,
var previousValue = g_form.getValue('u_expected_remediation_date');
if(previousValue != null && previousValue != newValue) {
g_form.setVisible('u_reason_for_updated_remediation_date', true);
g_form.setMandatory('u_reason_for_updated_remediation_date', true);
}
Please Mark as Correct or Hit Like or Mark as helpful if Helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 03:01 AM
Finally this one helped. Thank you all for your suggestions.
if (oldValue == null)
{
g_form.setVisible('u_reason_for_updated_remediation_date', false);
}
else if (oldValue != newValue){
g_form.setVisible('u_reason_for_updated_remediation_date', true);
g_form.setMandatory('u_reason_for_updated_remediation_date', true);
}
else{}
}