Auto populate assignment group on clicking UI action

Supratik3
Tera Expert

Hi all,

We have a custom Candidate table, where a record is created though record producer. One of the fields in this Candidate form is Region- a choice field.

 

Once we open the Candidate record on application side, there is a UI action 'Create Task', which on clicking, opens a new Candidate Task form, where it needs to be submitted by filling a few fields. 

 

One of the fields on this Candidate Task form is 'Assignment Group'. The ask is to auto populate this Assignment group field on the Candidate Task form- based on the Region field in the parent Candidate form, when the Create Task UI action is clicked. 

 

For example- if the Region in parent Candidate field is APAC then on clicking Create Task, set assignment group to 'APAC group'; If Region is EMEA, then on clicking Create Task set assignment group to 'EMEA group' etc.

 

Please assist in how this can be done. Thanks in advance!

10 REPLIES 10

@Ankur Bawiskar 

 

Below is the script for the Create Task button, where few fields from the parent 'Candidate'  record (sn_candidate) are being set on this new 'Candidate Task'  (sn_candidate_task) form. FYI this button is on the parent form, i.e. Candidate(sn_candidate).

 

var newTask = new GlideRecord("sn_candidate");
newTask.initialize();
newTask.setValue("parent", current.sys_id);
newTask.setValue("state",'1');

newTask.setValue("u_referring_person_name", current.getValue("u_referring_person_name"));
newTask.setValue("u_role_title", current.getValue("u_role_title"));
newTask.setValue("u_country", current.getValue("u_country"));

action.openGlideRecord(newTask);

@Supratik3 

As already shared

if you know the region then you can set the assignment group during the redirection to new record

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Utpal Dutta
Tera Guru

Hi @Supratik3,

However I agree with Ankur but if you still don't want to use assignment rules then you can simply copy the query from list view and pass it in the URL where UI action is opening the form.

 

  1. First go to Candidiate task form list view and create a filter with the assignment group that you want to populate on the form.
  2. After filter is created copy the filter query like below.UtpalDutta_0-1753270487385.png
  3. Then open the UI action button which is opening the catalog task form.
  4. In this UI action you can run server script and get the value of Assignment group from current record's region field.
  5. Then in UI action you will have a link something like (/task.do%3Fsys_id%3D-1) which is opening the new catalog task form.
  6. You can then modify this url to have the query like this (/incident.do%3Fsys_id%3D-1&sysparm_query=PASTE QUERY THAT YOU COPIED)
  7. After this when you click on the UI action it will open the task form with Assignment group populated in it.

 

I hope this answer helps, if it does then please mark my answer Helpful & Accept this solution.

 

Let me know if you still need more help

Thanks,

 

Hi @Utpal Dutta ,

 

Thanks for responding.

 

Could you please guide on how to acheive the ask through assignment rules? Much appreciated!

 

This ServiceNow Documentation will guide you on how to create an assignment rule. You can make use of script field for complex condition logic but assignment rules only work when record is inserted or updated.