Business rule to create request item in a Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 09:27 PM
Hi All,
I have to create a Business rule on sys_user for any new records created by "ta_admin" then create that new user request with the variable incident management role as ‘normal user’ in the Tenforce catalog item.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 10:32 PM
Hi @Dileep2
Could you please clarify your requirements in more detail? From what I understand, you want to submit a Catalog Item through a Business Rule. This Catalog Item includes a variable for the Incident Management Role, and you would like the value of this variable to be set as "Normal User."
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 12:49 AM
Hi @Dileep2,
Try with following script in BR.
(function executeRule(current, previous /*null when async*/) { var req = new GlideRecord('sc_request'); req.initialize(); req.requested_for = current.sys_id; // Set the new user's sys_id req.cat_item = '9a01ae80838112103fcc95d0deaad39e'; // Replace with actual sys_id of the Tenforce catalog item req.short_description = 'User role assignment for ' + current.user_name; var reqID = req.insert(); // Insert the request var ritm = new GlideRecord('sc_req_item'); ritm.initialize(); ritm.request = reqID; ritm.cat_item = '9a01ae80838112103fcc95d0deaad39e'; // Same catalog item as menetioned above ritm.requested_for = current.sys_id; // Associate with the new user ritm.short_description = 'Role assignment for ' + current.user_name; var ritmID = ritm.insert(); // Insert the RITM var each_variable = new GlideRecord('sc_item_option'); each_variable.initialize(); each_variable.item_option_new = '44816ac0838112103fcc95d0deaad3aa'; // varible sys_id like my catlog item requested for and type so I provided sys id of requested for each_variable.value = current.sys_id; // sys id of requested for var get_each_var = each_variable.insert(); // for each varible you have to create a record in sc_item_option like above // Assigning the role variable to the RITM var variable = new GlideRecord('sc_item_option_mtom'); variable.initialize(); variable.request_item = ritmID; // Associate with the new RITM variable.sc_item_option = get_each_var; var sys_var = variable.insert(); })(current, previous); |
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi