OnSubmit Client script to set value of assignment group

Deepika Mishra
Mega Guru

I am trying to set value of assignment group using client script on onSubmit functionality, but the below code is not working. Please help :
find_real_file.png

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

You should use an Assignment rule. All that script is doing is setting an assignment group variable, not the assignment group on the record.

View solution in original post

25 REPLIES 25

@Deepika Mishra best practice would be to use an Assignment Rule for this, rather than any type of script, because otherwise you may suffer the side effects of a hard-coded sys_id, e.g. what if in the future there needs to be a change to a different group? the script would need to be changed = a customisation rather than configuration,

So, to understand how to set up an "Assignment Rule" check this link,

Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

Module name is Assignment rule.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you should be using normal client script for this and not Catalog Client Script.

if authority is a variable then use this syntax to get the value

function onSubmit(){

if(g_form.getValue('variables.authority').toString() == 'true'){

g_form.setValue('assignment_group', 'sysIdHere');

}

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

you should be using normal client script for this and not Catalog Client Script - will it work on portal then ?

Hi,

yes it would work on portal as well when you open the record in form page

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader