- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 05:33 PM
i followed the article : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0852249
1. Add a new custom 'Requested For' [u_requested_for] field to the 'sc_req_item' table.
2. Add a variable['requested_for'] at the item level to capture the user for whom this item is requested.
3. Create a Before insert business rule on 'sc_req_item' table to copy the value of variable ['requested_for'] to the sc_req_item.u_requested_for field using code that looks like below:
current.u_requested_for = current.variables.requested_for; // Copy the variable value to the RITM's Requested For field
from my flow designer , i have a variable name_of_user in the stashbucket, how can i use it to update the requested for field on the Request item form?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 10:54 PM
@chercm try changing the before insert business rule to after Insert business rule and change the code to below one.
Create a new before insert Business rule on table sc_req_item and add the following script.
(function executeRule(current, previous){
var gr = new GlideRecord('sc_request');
if(gr.get(current.request)){
gr.requested_for = current.variables.name_of_user;
gr.update();
}
})(current, previous)
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 08:05 PM
@chercm post the screenshot of variable configuration and business rule and the ritm form.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 09:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 09:34 PM - edited 10-07-2023 09:35 PM
@chercm do the following changes.
1. Variable Setup: Change the value field to sys_id, and label(s) field to name.
2. Create a new before insert Business rule on table sc_req_item and add the following script.
(function executeRule(current, previous){
var gr = new GlideRecord('sc_request');
gr.get(current.request);
gr.requested_for = current.variables.name_of_user;
gr.update();
})(current, previous)
Try these and let me know.
Please mark my answer helpful and accept as solution 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 10:24 PM - edited 10-07-2023 10:30 PM
it is still showing as current user. not working
getting this error. :
ErrorUnique Key violation detected by database ((conn=49635) Duplicate entry 'f1b7f6382f353110207170682799b6d9' for key 'PRIMARY')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 10:54 PM
@chercm try changing the before insert business rule to after Insert business rule and change the code to below one.
Create a new before insert Business rule on table sc_req_item and add the following script.
(function executeRule(current, previous){
var gr = new GlideRecord('sc_request');
if(gr.get(current.request)){
gr.requested_for = current.variables.name_of_user;
gr.update();
}
})(current, previous)
Anvesh