Onchange Client script in mobile agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 03:18 AM
Hi All,
I required to implement the follow logic on Incident:
An user should select 'Assignment group change reason' according to change of Assignment group change.
for example:
In case the assignment group was change: from 'MRC' to any other value the 'Assignment group change reason' field will appear with the relevant set of options.
In case assignment group was change: from 'MSE' to 'WHENG' the 'Assignment group change reason' field will appear with other relevant set of options.
In order to implement it:
1. I added 'Assignment group change reason' field to Incident table and define the several set of choices related to the changes defined by 'depended values'. for example all the choices with depended value 'fromMRC' will present in case the assignment group was change from 'MRC' to any other value. (Please see attached)
2. added the follow client script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || oldValue === '') {
return;
}
var dependentValue = '';
var nag = new GlideRecord ('sys_user_group');
nag.get(newValue);
var oag = new GlideRecord ('sys_user_group');
oag.get(oldValue);
if(oag.name == 'MRC')
{
dependentValue= 'fromMRC';
}
else if(oag.name == 'MSE' && nag.name == 'WH ENG')
{
dependentValue= 'MSEToWHENG';
}
else if(oag.name == 'WH ENG' && nag.name == 'MSE')
{
dependentValue= 'WHENGToMSE';
}
if (dependentValue != '')
{
g_form.clearOptions('u_assignment_group_change_reason');
g_form.setValue('u_assignment_group_change_reason','','');
g_form.setMandatory('u_assignment_group_change_reason',true);
var choices = new GlideRecord('sys_choice');
choices.addQuery('element','u_assignment_group_change_reason');
choices.addQuery('dependent_value',dependentValue);
choices.query();
while(choices.next())
{
g_form.addOption('u_assignment_group_change_reason',choices.value,choices.label,choices.sequence );
}
g_form.setVisible('u_assignment_group_change_reason',true);
}
}
It is working fine on web but not on mobile agent. (I added same script to mobile agent but it is not working).
Any Idea how to implement same logic on mobile agent?
- Labels:
-
Agent Mobile App
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 10:13 AM
Try to use a smart button, URL type.
Context: Record;
URL link: /mesp?id=form&table=incident&sys_id={{sys_id}};
URL label: The name that will show up at the top of the screen;
This Smart Button will catch up the Mobile Service Portal view, and your client script should be Mobile/Service Portal type. All your logic will be captured there, and this smart button does not works in offline mode.