- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 01:59 AM
Hi Team,
Can somebody help me on this.
i am trying to copy values from variables(which are in Variable set) to fields in RITM Table by using Business rule.
By using below script in my after business rule which is on the sc_req_item table values are not copied.
(function executeRule(current, previous /*null when async*/) {
// Note: if i am using if condition like this values are NOT Copied. and if i remove if condition values are copied.
if((current.variables.standard_employee_questions.check_this_box=='true')&&(current.variables.standard_employee_questions.needed_by=='today')){
current.u_requestor = current.variables.standard_employee_questions.requested_for;
current.update();
}}
)(current, previous);
Please let me know how to resolve this? and i can't use run script activity in workflow as my variable set is used in multiple catalog items and they have different workflows. i don't want to modify all the workflows.
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 03:04 AM
This works fine with a before Insert Business Rule. When referring to variables in a workflow or BR script, use the syntax current.variables.variable_name, not current.variables.variable_set_name.variable_name, so this script will work.
(function executeRule(current, previous /*null when async*/) {
if(current.variables.check_this_box.toString() =='true' && current.variables.needed_by == 'today'){
current.u_requestor = current.variables.requested_for;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 03:04 AM
This works fine with a before Insert Business Rule. When referring to variables in a workflow or BR script, use the syntax current.variables.variable_name, not current.variables.variable_set_name.variable_name, so this script will work.
(function executeRule(current, previous /*null when async*/) {
if(current.variables.check_this_box.toString() =='true' && current.variables.needed_by == 'today'){
current.u_requestor = current.variables.requested_for;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 03:20 AM
Hi Ankur and Brad,
Thanks for the Help!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 03:26 AM
You are welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 05:23 AM
Glad to help.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader