Assignment rule depending on variable

Cristina Esteve
Tera Contributor

Hi guys!

 

I have created a variable inside a Catalog item that it's a reference type to the table service_offering. I have called it assignemnt_group. This variable is working fine.

Then I have created the Assignment rule that applies to this item, but the script is not working for me.

I have tried with several things, no good results. There is a way I can do this, but with the variable instead with an specific value?

 

current.assignment_group.setDisplayValue("name_of_assignment_group_2");

 

1 ACCEPTED SOLUTION

Hi Cristina,

if the assignment group is on service catalog form this works

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
 
    if (newValue == 'Other') {
        g_form.setValue('assignment_group', 'ffb84337db3d2410ca98166f299619c5');
    } else {
        g_form.setValue('assignment_group', '04c88337db3d2410ca98166f29961943');
    }
}

if you need you need Assignment group to be picked from catalog variable
you can proceed with Assignment Rule, Flow Designer or BR Approach with below script can be used in Assignment Rule and Before BR on insert

if (current.variables.assignment_group) {
current.assignment_group = current.variables.assignment_group.toString();
}
with Flow get the Catalog variable action and update the RITM record.

if the solution works kindly mark helpful

Regards
Sudhanva Chandra D
Certified ArchX || 8x ServiceNow CIS

View solution in original post

6 REPLIES 6

Cristina Esteve
Tera Contributor

By the way, this is not working:
current.assignment_group.setValue(current.variables.assignment_group)

Tejas Adhalrao
Mega Sage

hi @Cristina Esteve  ,

 

Since your catalog variable is a reference to the service_offering table, first check what value it returns. Also, make sure the reference variable name is correct.

You can try the following in your Assignment Rule script:

var offering = current.variables.assignemnt_group;

if (offering) {
    current.assignment_group = offering;
}

However, there is one important point: your variable references service_offering, while current.assignment_group normally references sys_user_group. These are different tables, so you cannot directly assign the service offering sys_id to the assignment group field.

If you want to set the assignment group based on the selected service offering, query the relevant service offering record, retrieve the associated assignment group, and assign that group's sys_id to current.assignment_group.

 

If this helped, mark it helpful and accept the solution.

Regards, Tejas

Ehab Pilloor
Giga Sage

Hi @Cristina Esteve,

 

You are trying to add reference of service offering table to group table. Instead, do a glide record on group table, query by name contains service offering and return that group in assignment rule.

 

Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.

 

Kind Regards,

Ehab Pilloor

Sudhanva1
Tera Expert

Hi Cristina,

Please use the below script in assignment rule and make sure it should only Applies to is set with proper item condition

if (current.variables.assignment_group) {
current.assignment_group = current.variables.assignment_group.toString();
}

variable name should be "assignment_group " and mapping field in ritm or any task should be "assignment_group"

if the solution works kindly mark helpful

Regards

Sudhanva Chandra D
Certified ArchX || 8x ServiceNow CIS