How to show Annotation section , based on 3 conditions using onChange Client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2025 09:42 AM
Hi All,
I have a requirement to show Annotation section, if 3 conditions are satisfied and these 3 condtions are from 3 individual fields which are choice type.
and I have written a onChange client script for achieving this , but i am able get only 1st field value , others are coming as empty , so condition is not satisfying to show Annotaion section.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var a1= g_form.getValue('compliance_risk');
var a2= g_form.getValue('complexity_risk_global_and_functional');
var a2= g_form.getValue('operational_risk');
alert('1st--'+ a1);
alert('2nd--'+a2);
alert('3rd--'+a3);
if (a1== 'yes, direct impact' && a2== 'global department' && operationalrisk == 'Yes, Quality Agreement '){
$('primPurpose').up().show();
g_form.setDisplay('primary_purpose_of_document', true);
//Type appropriate comment here, and begin script below
}
}
So please suggest me how to achieve this requirement.
Appreciate your support.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2025 08:52 AM - edited 02-09-2025 08:53 AM
@Neelavathi M We are glad that you fix the script.
If any of our suggestions has helped you feel free to hit helpful button and select correct answer for this thread. As per new feature you can select multiple correct answer.
Thanks & Regards,
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2025 10:33 PM
Hello @Neelavathi M
If you want the onChange script to trigger for three different fields, you need to create separate onChange client scripts for each field.
Try the following script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var a1 = g_form.getValue('compliance_risk');
var a2 = g_form.getValue('complexity_risk_global_and_functional');
var a3 = g_form.getValue('operational_risk');
alert('1st -- ' + a1);
alert('2nd -- ' + a2);
alert('3rd -- ' + a3);
if (a1 == 'yes, direct impact' && a2 == 'global department' && a3 == 'Yes, Quality Agreement') {
$('primPurpose').up().show(); // Prototype.js way of selecting elements
g_form.setDisplay('primary_purpose_of_document', true);
} else {
$('primPurpose').up().hide();
g_form.setDisplay('primary_purpose_of_document', false);
}
}
- This onChange script will trigger only when the specific field it is assigned to changes.
Note: Make sure the conditions under if block are built using the choice value and not the label.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2025 08:34 AM
Hi @Juhi Poddar ,
Thanks for reply, I have fixed it , by creating Onchange script on 3rd field, by the selection of 3rd field on the form, 1st and 2nd values would be entered by the user, so fetching those values and comparing those , and then populating the Annotation Section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 06:32 AM
I am working on something similar and wanted to understand what's "primPurpose" here ? Is this Annotation ID using which we can select particular annotation ?
$('primPurpose').up().show();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 07:13 AM