- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:00 AM
Hello,
I am making Business Rule that checks incident number and gets it's sys id.
Problem is how can i make a script that checks my display value for example "INCE0012345" as a query?
var inc = new GlideRecord('incident'); query that queries the display value and return sys id of this ince0012345 | |
inc.addQuery("sys_id", 'this is ince0012345 sys id'); | |
inc.query(); |
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:30 AM
To display the sys_id you need to do:
var gr = new GlideRecord('incident');
gr.addQuery('number', 'INCE0014635');
gr.query();
while(gr.next()){
gs.print(gr.sys_id);
}
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:08 AM
Try this:
var gr = new GlideRecord('incident');
gr.addQuery('number', 'INC0053029');
gr.query();
gs.print(gr.getRowCount());
and I get on my own instance:
[0:00:00.021] Script completed in scope global: script
*** Script: 1
If you are in the current scope you can also use:
gr.addQuery('number', current.number);
Replace the incident number you want.
Regards
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:22 AM
var a = "INdfCE RITM INsadCE INCE0014635 asdf"
var b = Math.max(a.indexOf("INCE"), a.indexOf("RITM"))
gs.print(b);
var start = a.indexOf('INCE'); // gets the index where INCE starts
var end = a.indexOf(' ', start); // gets the index where INCE ends
var recordNumber = a.substring(start, end).toString();
gs.print(recordNumber);
var gr = new GlideRecord('incident');
gr.addQuery('number', 'recordNumber');
gr.query();
gs.print(gr.getRowCount());
it didn't print rowCount as 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:32 AM
Is your recordNumber getting printed properly ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2015 02:17 AM
Hello Hai,
If you want to grab the sys_id of the record that triggered the business rule, you can use this:
var mySysID = current.sys_id;