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

mayankkumar
Tera Sage

Hi @Supratik3,
I got your requirement, I've tried to implement the same using UI Action(client) and Client script on the target table
Approach is you can pass the value of your region in the url parameters and then write a onLoad client script in which you are going to fetch the region value passed via UI Action and then using that value you need to GildeAjax and find the related Assignment group sys_id in the script include and then set your Assignment Group on Candidate task table

I tried to autopopulate the impact value on the problem record from incident

Ui Action script-:

// UI Action Script
function problem() {
	var impact = g_form.getValue('impact');
	var url = '/problem.do?sys_id=-1' + '&impact=' + impact;

	window.open(url, '_blank');
}


Client Script on Target Table-:

function onLoad() {
	if (g_form.isNewRecord()) {
		var url = new GlideURL(window.location.href);
		var myParam = url.getParam('impact');
		if (myParam) {
			g_form.setValue('impact', myParam);
		}
	}

}

 
Also, you can do it with server side Ui Action but then it directly creates the Problem record like this-:

if (!current.assignment_group) {
    gs.addErrorMessage("Assignment Group is required to create a Problem.");
    action.setRedirectURL(current);
    return;
}

// Create new Problem record
var prob = new GlideRecord('problem');
prob.initialize();
prob.assignment_group = current.assignment_group;
prob.short_description = current.short_description;
prob.description = current.description;
prob.insert();

gs.addInfoMessage("Problem record created and opened.");

// Redirect to the new Problem record
action.setRedirectURL(prob);

Now it's up to you, which one you want to use
I don't think using assignment rule you can set values on another table New Record
Rest Correct me if am wrong here
-------------------------------------------------------------------------------------------------------------------------------------------------
Please Mark my response helpful and accept as solution.
Thanks & Regards
Mayank