script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 11:10 AM
Hi All,
I am writing After Business Rule, and have created Problem ticket when Incident is "on hold".
In addition I want to update Incident Ticket as well, with Problem created. How we can achieve this?
Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2025 09:24 PM
Since you mentioned my script worked.
Please mark my response as correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 05:20 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 12:53 AM
If my response worked, please mark my response as correct and close the thread.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2025 03:46 AM
Hi @BharatiK ,
The Script you mentioned is correct but a small script error.
Please refer to the below script:
Script: (BharatiK - Script)
But for your reference, the best practice is not to use current.update() in BRs but if you want to use current.update() in BRs then please refer to the below script
script:
current.problem_id = gr.sys_id.toString();
current.setWorkflow(true); //hence the update is completed, setWorkflow(true) will help to enable all the Business Rules on the record.
I hope this information will help you and happy learning.
Thanks,
Koteswara Vara Prasad M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2025 04:16 AM
Hi @BharatiK ,
I would suggest you to use flow, and if you are okay with business rule the after update BR would be right choice.
If you use before BR then then you will create loop whole, lets say in a scenario update failed by other BR on that case problem will be created but it wont be mapped to incident.
After BR code you case use like below.
var gr = new GlideRecord('problem');
gr.initialize();
gr.short_description = current.short_description;
gr.cmdb_ci = current.cmdb_ci;
var probRec = gr.insert();
if (probRec) {
// Connect the problem record back to this incident
current.setWorkflow(false); // Prevent triggering unnecessary workflows
current.setValue('problem_id', probRec);
current.update();
} else {
gs.log('Failed to create Problem record.');
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------