Built-in Validation Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 03:04 AM
Hello Guys,
I would like to use the ServiceNow existing Validation Script, in order to validate the record producer field. I think the best way to use it is with Client Script but I have no idea how do I supposed to do that.
Any information about that can help a lot.
Best wishes,
Shay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 03:17 AM
Client script is how you do field validation in most cases.
Record Producers and Catalog Items have their own place for client scripts though. Go to your Record Producer form, add the related list for "Catalog Client Script", and you can add a new one from there.
Assuming you know what to do once you get to the Client Script. If not, let me know what you want to validate and I can possibly help generate it for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 07:34 AM
Hello robert ,
Need some help in validating this script , not sure if i can ask it here , excuse me
here is the sceneria ,
i have an RITM and sctask in it , il close the sctask and then this task is related to change
what i need is in the ritm workflow
i have an if condition to see if the change state has changed to close (3) . but iam getting it , below is the script m using , i know there is something wrong but dnt have the expertise to figure out
function ifScript()
{
var curID10 = current.sys_id; // this is the sys_id of RITM since iam on the ritm workflow i,e catalog item workflow
var rec10 = new GlideRecord('sc_task'); // task table
rec10.addQuery('request_item', curID10 );// query request_item field with curID10(RITM number)
//hope rec10 now is having the sctask number
var rec11 = rec10.parent; //this parent field in sctask form has teh change number so thot rec10.parent will get it
var change = new GlideRecord('change_request'); // change form
change.addQuery('sys_id',rec11); looking up change with number from rec 11
change.query();
while (change.next())
{
if(change.state == 3)
gs.addInfoMessage('state is 3');
{
return 'yes';
}
gs.addInfoMessage('change is not 3');
return 'no';
}
}
I dont know where iam going wrong
can you please suggest , or is there any other to get the change state in the RITM workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 07:43 AM
Try below- for rec10.addQuery('request_item', curID10 );, you did not query the record.
function ifScript() {
var curID10 = current.sys_id; // this is the sys_id of RITM since iam on the ritm workflow i,e catalog item workflow
var rec11 = '';
var rec10 = new GlideRecord('sc_task'); // task table
rec10.addQuery('request_item', curID10); // query request_item field with curID10(RITM number)
rec10.query();
if(rec10.next()){
//hope rec10 now is having the sctask number
rec11 = rec10.parent; //this parent field in sctask form has teh change number so thot rec10.parent will get it
}
var change = new GlideRecord('change_request'); // change form
change.addQuery('sys_id', rec11); //looking up change with number from rec 11
change.query();
while (change.next()) {
if (change.state == 3)
gs.addInfoMessage('state is 3'); {
return 'yes';
}
gs.addInfoMessage('change is not 3');
return 'no';
}
}
Thanks.
PS: Hit like, Helpful, Correct and Endorse, if it answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2017 07:19 AM
Hello Nisha, Thankyou for your help
No luck
its just going yes in If condition even if the state is not three
its not getting the value , there is something iam missing . Please let me know if you find anything