How to copy incident Affected user to Catlog item Requested for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi,
I need to Create a Request from an Incident by using context menu(UI Action), but when I select any catalog Item Requested for is not getting auto populated(same as incident Affected User). I have written one BR but it seems not working.
BR: Copy Affected User to Requested For
Table: sc_request
When: Before
Insert
Update
Condition: Parent is not Empty
Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
so what are your findings with the BR?
is the field name correct? affected_user
I couldn't see that as OOTB field
if it's custom field then it must be starting with u_
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi @jugantanaya,
1. Wrong table – You're using sc_request, but the "Requested for" field actually lives on the RITM (sc_req_item). The request header doesn't have that field.
2. Parent field is tricky – When you use the "Create Request" UI action, current.parent isn't always populated yet. So your condition might be failing right there.
3. Variables won't work here – current.variables doesn't work in a Business Rule on sc_request. That's just not how it's designed.
4. Field name check – As others mentioned, affected_user isn't an OOTB field on incident. If you created it custom, it should be u_affected_user.
Option 1: Fix it in the UI Action
Instead of a Business Rule, just set the value when you create the cart:
var cart = new Cart(); var item = cart.addItem('your_catalog_item_sys_id'); // Grab the affected user from the incident cart.setRequestedFor(current.u_affected_user || current.caller_id); var rc = cart.placeOrder(); action.setRedirectURL(rc);
This works every time because you're setting it before the RITM is even created.
Option 2: Move your Business Rule to the right table
If you really want a Business Rule, put it on sc_req_item instead:
(function executeRule(current, previous) { if (current.request && current.request.parent) { var inc = new GlideRecord('incident'); if (inc.get(current.request.parent)) { current.requested_for = inc.u_affected_user; // or inc.caller_id } } })(current, previous);
