- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 12:04 PM
Hello Community,
I am trying to get a variable called "ritm_short_description" on the catalog item to populate the "short_description" field on the request item.
Here is the catalog item:
Here is the variable on the catalog item:
Here is how I would like it to be displayed as after the catalog item has been submitted and is now a request item:
I have been trying workflows and business rules and i am not sure what i am doing wrong.
Please help!
Thanks in advanced.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2016 03:43 PM
Did you try this in the workflow in the run script activity. This run script activity should be your first activity in the workflow. Or you could also write a before business rule on the sc_req_item table
Run script activity:
current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;
Business rule:
When: before insert
Conditions: Item is <select the catalog item>
Script:
current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2016 04:38 PM
Hello Abhinay,
Your method worked.
I wish I can give you all credit for the answer!
Here are the screen shots of the script
if(current.short_description.indexOf(current.variables.ritm_short_description) < 0) {
current.short_description = current.short_description+" "+current.variables.ritm_short_description;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2016 04:48 PM
Glad you got it working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2016 04:12 PM
Hello, is the business rule setup to run "before" or "after"? If you do it "after", you need to have "current.update();". I recommend executing it as "before" rule for simple things like that. This will ensure all changes to the current record happen at once. Also, note that the logic I gave is good for "insert". If you have a use case like the variable getting changed later on, you need to do it differently.
Here is roughly how you would have in a business rule that is setup to run "before" and for insert/update cases. The idea is that you are always building the new description based on the catalog item short description and the variable and comparing it to what's in the request item short description.
var newDescription = getShortDescription(current);
if(current.short_description != newDescription)
current.short_description = newDescription;
function getShortDescription(gr /* ritm gr */) {
var cat_short_description = gr.cat_item.short_description;
if(gr.variables.my_variable) {
return gr.cat_item.short_description+" "+gr.variables.my_variable;
}
else
return gr.short_description;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2016 04:20 PM
Moe information on why before business rule is. You need to use before business rule when you are updating something on the current record and use after business rule when you are updating something on the related records not the current record. Also never use current.update() since it triggers business rules to run on the same table for insert and update operations, leading to a business rule calling itself over and over.
http://wiki.servicenow.com/index.php?title=Business_Rules_Best_Practices#gsc.tab=0