- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 12:39 AM
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();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 02:47 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 12:47 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 12:54 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 01:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2020 02:47 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader