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

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.

Thank you Brad!

I found that one of my variables was misspelled (assigment_group) so nothing was going to happen until I noticed that too.

Works perfectly!

Thank you for the education!

 

Cheers

A.