- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2025 01:14 AM
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
‎09-02-2025 01:27 AM - edited ‎09-02-2025 01:29 AM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2025 01:52 AM
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().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2025 01:27 AM - edited ‎09-02-2025 01:29 AM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2025 01:50 AM
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
‎09-02-2025 01:52 AM
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().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2025 04:08 AM
Thanks @Ravi Gaurav both helped.. I implemented and it worked for me as per you suggestion. Please continue helping us ..