The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Catalog Item Request form: How to auto-populate the assignment group field based on CI chosen?

Shawn Horley
Kilo Guru

Greetings Folks

Another scripting question (Ah! the hits just keep on coming don't they?)

So I am building Catalog Item forms for specific requests. In this case a User Access Request. The challenge is I need to script it so that the form auto-populates the Assignment Group based on the CI chosen. The assignment group will be the same as The CI assignment group in the CMDB.

I just don't know the language to do this, or whether it should be a catalog client script or some other variant.

Any help will be most appreciated!

Cheers

A.

1 ACCEPTED SOLUTION

You shouldn't need to modify the group variable, but I did just realize my script has a scope issue. It should look like this:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	
    var ciVar = 'configuration_item';
    var ci = g_form.getReference(ciVar, getGroupCallback)

}

function getGroupCallback(ci) {
    var asgVar = 'assignment_group';
    g_form.setValue(asgVar, ci.assignment_group);
}

Also, the variable name on the catalog client script record should be configuration_item rather than assignment group. You're telling it which field to monitor for changes, which should be the CI field.

View solution in original post

6 REPLIES 6

anubhavkapoor76
ServiceNow Employee
ServiceNow Employee

It will be an Catalog Client Script to do this.

Cheers!!

Anubhav

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would use an onChange catalog client script that runs against your CI variable. It would look something like:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	
	var ciVar = 'name_of_ci_variable';
	var agVar = 'name_of_assignment_group_variable';

	var ci = g_form.getReference(ciVar, getGroupCallback)

}

function getGroupCallback(ci) {
	g_form.setValue(agVar, ci.assignment_group);
}

g_form.getReference Documentation

Hi Brad!

Thanks for this. I'm trying it now, I've set the script up like this:

 find_real_file.png

But I realize I have to modify the Assignment Group reference field as well... somehow.

I had it referencing the Group [sys_user_group] table and the ref qualifier was 'Simple' with the Name is not empty filter so that a list would be provided when the field was clicked. I had Help Desk set as the default.

I was wondering how I should modify the Assignment Group field to take input from the script?

Cheers

A.