- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2015 02:11 AM
Hi all,
Split the string from description and get the id and set it in the name and location field. any help in this will be highly appreciated.
Business rule:
function onBefore(current, previous) {
//This function will be automatically called when this rule is processed.
//var desc = current.description;
var desc = "EMPLOYEE ID : 125316 Lan ID : test ";
var splited=desc.split(":");
var str1 = splited[1];
var str = str1.split("Lan");
var mystr = str[0];
gs.addInfoMessage(mystr);
var qry = new GlideRecord('sys_user');
//qry.addQuery('user_name',mystr);
qry.addEncodedQuery('user_name='+mystr); // if i give the id directly here its working fine.
qry.query();
if(qry.next())
{
gs.addInfoMessage("first");
current.u_user=qry.sys_id;
current.u_location=qry.location;
gs.addInfoMessage("Sucessfull");
}
}
Regards,
Alad.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2015 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2015 02:58 AM
Hi Anto,
user_name is employee id in your case? if it is so, your code should be
qry.addQuery('user_name',mystr.toString());
just try with this line and check.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2015 03:13 AM