UI action issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 04:48 AM - edited 08-10-2023 04:53 AM
Hi Team ,
We have wrote a script on UI action below .
if (current.subcategory == '80') {
if (current.u_approval_required == '1US') {
alert('1US');
current.state = 19;
current.assignment_group = 'OTC COE US Manager 1';
}
if (current.u_approval_required == '2US') {
alert('2US');
current.state = 19;
current.assignment_group = 'OTC COE US Manager 2';
}
should go to pending approval
when we click on UI action state should be Pending on approval state , but it is not happening
could you please guide me ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:03 AM
your script is wrong.
Script seems to be server side since you are using current object and alert won't work there
Use gs.addInfoMessage() and use setDisplayValue to set the group
if (current.subcategory == '80') {
if (current.u_approval_required == '1US') {
gs.addInfoMessage('1US');
current.state = 19;
current.setDisplayValue('assignment_group', 'OTC COE US Manager 1');
}
if (current.u_approval_required == '2US') {
gs.addInfoMessage('2US');
current.state = 19;
current.setDisplayValue('assignment_group', 'OTC COE US Manager 2');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:36 AM
getting below error
Function setDisplayValue is not allowed in scope sn_customerservice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:09 AM
Hi @pramn
something like this should help -
if (current.subcategory == '80') {
var approvalRequired = current.u_approval_required;
var targetGroup = '';
if (approvalRequired == '1US') {
gs.addInfoMessage('1US');
targetGroup = 'OTC COE US Manager 1';
} else if (approvalRequired == '2US') {
gs.addInfoMessage('2US');
targetGroup = 'OTC COE US Manager 2';
}
if (targetGroup) {
current.state = 19;
current.setDisplayValue('assignment_group', targetGroup);
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar