- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
You must update an Incident, create 3 related RITMs, and upsert 150 CI relations atomically. If any step fails, everything must roll back. How would you implement this in scoped apps using GlideRecord, background scripts, or GlideTransaction patterns—without relying on Flow Designer? Discuss pitfalls around BR recursion and after-commit work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
Solution approach
-
Use a Script Include to handle everything in one try/catch.
-
Keep arrays of created sys_ids (RITMs, CI relations).
-
If any step fails:
-
Revert Incident to old values.
-
Delete inserted RITMs.
-
Delete inserted CI relations.
-
-
Guard recursion with a session flag (gs.getSession().putProperty()).
-
Suppress after-commit notifications during this batch (add conditional checks in BRs).
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ď”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ď”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
gs.getSession().putProperty() is a server-side method in ServiceNow used to store a custom property within the current user's GlideSession. This property can then be retrieved later in the same session using gs.getSession().getProperty().
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ď”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ď”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
Solution approach
-
Use a Script Include to handle everything in one try/catch.
-
Keep arrays of created sys_ids (RITMs, CI relations).
-
If any step fails:
-
Revert Incident to old values.
-
Delete inserted RITMs.
-
Delete inserted CI relations.
-
-
Guard recursion with a session flag (gs.getSession().putProperty()).
-
Suppress after-commit notifications during this batch (add conditional checks in BRs).
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ď”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ď”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Thanks ravi as usual.. can you explain the gs.getSession().putProperty()).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
gs.getSession().putProperty() is a server-side method in ServiceNow used to store a custom property within the current user's GlideSession. This property can then be retrieved later in the same session using gs.getSession().getProperty().
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ď”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ď”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Thanks @Ravi Gaurav both helped.. I implemented and it worked for me as per you suggestion. Please continue helping us ..