- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 07:04 AM
Hello
I am trying to create a background script for closing a change, for which workflow has broken. Advise on it please.
function getUserRegion() {
var u = gs.getnumber();
var gr = new GlideRecord('change_request');
gr.addQuery('CHG00046',u);
gr.query();
while (gr.next()) {
gr.u_stage= 7;
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:18 AM
If you need to change the state, then update the script to use the state field instead.
var gr = new GlideRecord('change_request');
if (gr.get('number', 'CHG00046')) {
gr.state= 7;
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 07:12 AM
Hi Hari,
There's no method for gs called 'getnumber'. Try this instead.
function getUserRegion() {
var gr = new GlideRecord('change_request');
if (gr.get('number', 'CHG00046')) {
gr.u_stage= 7;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 07:27 AM
function getUserRegion() - is this name correct.
i need to access change_request table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 07:16 AM
This line might be your issue:
gr.addQuery('CHG00046',u);
Change it to gr.addQuery('number', 'CHG00046'); and it should work. Your change request number looks to be a little short. I'm used to seeing seven digits, and this one is five.
You can either hard-code the number, if you're using a fix script, or programmatically grab the record number using something like var u = current.number; but I don't think var u = gs.getnumber(); is doing anything for you.
(Beat me to it Chuck )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 07:29 AM
function getUserRegion() /* IS THIS CORRECT, AS I NEED TO ACCESS CHANGE RECORD */
{
var gr = new GlideRecord('change_request');
gr.addQuery('number', 'CHG00046');
gr.query();
while (gr.next()) {
gr.u_stage= 7;
gr.update();
}
