- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 12:35 PM
Hello I have a catalog item that is suppose to update a Incident after submission but I seem to be having problems with the script. The idea is that on the catalog item you select the incident you wish to update, the values like the current inc short description are populated.
When you submit whatever changes you made should then update the incident referenced in the field. I am doing this via a business rule but seem to be having some trouble here is my code.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("incident");
gr.addQuery('number', current.variable_pool.incident);
gr.query();
while (gr.Next()){
gr.caller = current.variable_pool.caller;
gr.short_description = current.variable_pool.short_description;
gr.description = current.variable_pool.description;
}
})(current, previous);
I should note the business rule triggers "after" insert of the catalog item.
Any assistance would be helpful thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2022 06:56 AM
Thank you all for your help it seems like the issue was a combination on what you all mentioned.
1. I had accidently made "Next()" capitalized.
2. I forgot the gr.update()
3. the variable for incident was mapped to sys id so I dot walked to incident.number.
4. Changing to a before business rule helped also.
Thank you for your assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 07:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 07:46 PM
Hi
Here in your Catalog Item, you are using Reference field for Incident.
It will return sys_id
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 03:38 PM
Don't you need gr.update() to write the info to the record, just like your query is not executed until you gr.query()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2022 06:56 AM
Thank you all for your help it seems like the issue was a combination on what you all mentioned.
1. I had accidently made "Next()" capitalized.
2. I forgot the gr.update()
3. the variable for incident was mapped to sys id so I dot walked to incident.number.
4. Changing to a before business rule helped also.
Thank you for your assistance.