How to set assignment group in an inbound email action.

Hari1
Mega Sage

Hi,

I have assigned the group name to a variable. I need to set the variable gp value to the assignment group field. This is a inbound email action. I am getting empty when i try to set the assignment group.

var str = "Name : ABC<br/>Volume Owner: Group Name<br/><br/>";
var regex1= /(.*)Volume Owner(:| )(.*)/i;
var ci1=regex1.exec(str);
var store1 = ci1[3];
var regex2 = store1.split("<br/>");
var sp = storeGroup.split(":");
var gp = sp[1];
var grinc = new GlideRecord('incident');
grinc.assignment_group.setDisplayValue(gp);
grinc.insert();
1 ACCEPTED SOLUTION

Hi Hemanth,

So you are able to get group name properly i.e. Data Center

I could see the value with comma i.e. , Data Center

Did you try to print variable value?

var value = trimvalue.substring(0, trimvalue.indexOf("<br/>"))

gs.info('Group is: ' + value);

I ran this in scripts background and able to get group name

var str = "Name : ABC<br/>Volume Owner: Group Name<br/><br/>";
var regex1= /(.*)Volume Owner(:| )(.*)/i;
var ci1=regex1.exec(str);
var store1 = ci1[3];
var regex2 = store1.split("<br/>");
var sp = store1.split(":");

var trimvalue = sp.toString().trim();

var value = trimvalue.substring(0, trimvalue.indexOf("<br/>"));

gs.info('Group is->' + value);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

8 REPLIES 8

Prasun
Giga Guru

Hi,

 

Try to use Gliderecord in group table and return the sys_id of the group and then set the sys_id in the assignment_group field.

 

Assignment group is a reference field, setting the value with sys_id will give you proper result.

 

Regards
Prasun

P.S. Please mark this correct if helps

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Hemanth,

please update code as below and it would give Group Name string from above

var str = "Name : ABC<br/>Volume Owner: Group Name<br/><br/>";
var regex1= /(.*)Volume Owner(:| )(.*)/i;
var ci1=regex1.exec(str);
var store1 = ci1[3];
var regex2 = store1.split("<br/>");
var sp = store1.split(":");

var trimvalue = sp.toString().trim();

var value = trimvalue.substring(0, trimvalue.indexOf("<br/>"))

var grinc = new GlideRecord('incident');
grinc.assignment_group.setDisplayValue(value);
grinc.insert();

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

With the above code that i posted i am getting the group name, But i am not able to set it using getDisplayValue. I even tried querying the sys_user_group table to get the sys_id but no luck.

Please find the below log of the code provided by you.

find_real_file.png

Hi Hemanth,

So you are able to get group name properly i.e. Data Center

I could see the value with comma i.e. , Data Center

Did you try to print variable value?

var value = trimvalue.substring(0, trimvalue.indexOf("<br/>"))

gs.info('Group is: ' + value);

I ran this in scripts background and able to get group name

var str = "Name : ABC<br/>Volume Owner: Group Name<br/><br/>";
var regex1= /(.*)Volume Owner(:| )(.*)/i;
var ci1=regex1.exec(str);
var store1 = ci1[3];
var regex2 = store1.split("<br/>");
var sp = store1.split(":");

var trimvalue = sp.toString().trim();

var value = trimvalue.substring(0, trimvalue.indexOf("<br/>"));

gs.info('Group is->' + value);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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