- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 06:13 AM
Hello,
I have to show some field message on the form when loaded but in that it should get the value of 'program manger' and 'backup program manager' fields value I mean what it is having so, I have written on lead clent script in 'demand' table like g_form.showFieldMsg('checkbox field value','this field is to be ticked by person A and person B ',"info");
Instead of A and B it should pick the values in those 'program manager' and 'backup program manager' those are in 'program' table
Thanks in advance ...
Solved! Go to Solution.
- Labels:
-
Demand Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 03:43 AM
Hmm, understood the issue, there is limitation of using getReference method i.e. you can only access data up to one dot only.
e.g. grProgram.program_manager this works but when you use grProgram.program_manager.getDisplaValue(), it is going for second dot, that is you are trying to access another record data which actually does not exist on client side.
In this case you would need to use Display BR or GlideAjax.
Please use below Display BR and client script to achieve your goal.
Business Rule :
BR script :
On load client script :
BR script for you to copy :
g_scratchpad.program_manager=current.primary_program.program_manager.getDisplayValue();
g_scratchpad.backup_program_manager=current.primary_program.u_backup_program_manager.getDisplayValue();
Client script for you to copy:
function onLoad() {
if (g_scratchpad.program_manager == "") {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.backup_program_manager);
} else if (g_scratchpad.backup_program_manager == "") {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.program_manager);
} else {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.program_manager +
'\n ' + g_scratchpad.backup_program_manager);
}
}
I haven't tested it practically but I am sure this would work, change field names properly if required.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 02:02 AM
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 02:54 AM
Plss find the code its not showing anything when form loads ...
if(g_form.getValue('primary_program')!='')
var grProgram = g_form.getReference('primary_program',showErrorMessage);
function showErrorMessage(grProgram)
{
g_form.showFieldMsg('u_program_manager' ,'This field is to be ticked by person ' + grProgram.program_manager.getDisplayValue() +
'\n ' + grProgram.u_backup_program_manager.getDisplayValue());
}
---> If i remove that get display it will show the sysid of that field values
In addition to that if program_manager or u_backup_program_manager is any field value is empty it should not display that value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 03:43 AM
Hmm, understood the issue, there is limitation of using getReference method i.e. you can only access data up to one dot only.
e.g. grProgram.program_manager this works but when you use grProgram.program_manager.getDisplaValue(), it is going for second dot, that is you are trying to access another record data which actually does not exist on client side.
In this case you would need to use Display BR or GlideAjax.
Please use below Display BR and client script to achieve your goal.
Business Rule :
BR script :
On load client script :
BR script for you to copy :
g_scratchpad.program_manager=current.primary_program.program_manager.getDisplayValue();
g_scratchpad.backup_program_manager=current.primary_program.u_backup_program_manager.getDisplayValue();
Client script for you to copy:
function onLoad() {
if (g_scratchpad.program_manager == "") {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.backup_program_manager);
} else if (g_scratchpad.backup_program_manager == "") {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.program_manager);
} else {
g_form.showFieldMsg('u_program_manager', 'This field is to be ticked by person ' + g_scratchpad.program_manager +
'\n ' + g_scratchpad.backup_program_manager);
}
}
I haven't tested it practically but I am sure this would work, change field names properly if required.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2022 07:06 AM
Hello Abhijit,
everything was working but instead of a/b its coming in one line even we have given |n also and one more thing is like if both program_manager and backup_program_manager are empty it should show anything but it is showing that test like this is ticked by ....