- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 04:55 AM
Hi All,
Around one requirement we need to create ritm based on string filed value like user can add multi user ids on this filed
(hr234;hr235;hr236), based on particular hr id create separate ritm for each Hr id.
So How can I achieve this requirement and Please help me on this.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 05:19 AM
Hi @vishalAg20
you can use Business Rule or Flow Designer as well for the requirement.
Create a business rule
Apply to Service Catalog Request [sc_request] or Service Catalog Item [sc_req_item]), based on where youāre capturing the user IDs.
When to run: After Insert or After Update (According to your convinience)
// Assuming āuser_ids_fieldā is the field that holds the ID string
var userIds = current.user_ids_field.toString();
var idsArray = userIds.split(';');
idsArray.forEach(function(id) {
// Logic to create a RITM for each ID
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.initialize();
ritmGR.short_description = "RITM for HR ID: " + id; // Customize based on your requirements
// Set other necessary fields
ritmGR.insert();
});
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning āā
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 05:19 AM
Hi @vishalAg20
you can use Business Rule or Flow Designer as well for the requirement.
Create a business rule
Apply to Service Catalog Request [sc_request] or Service Catalog Item [sc_req_item]), based on where youāre capturing the user IDs.
When to run: After Insert or After Update (According to your convinience)
// Assuming āuser_ids_fieldā is the field that holds the ID string
var userIds = current.user_ids_field.toString();
var idsArray = userIds.split(';');
idsArray.forEach(function(id) {
// Logic to create a RITM for each ID
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.initialize();
ritmGR.short_description = "RITM for HR ID: " + id; // Customize based on your requirements
// Set other necessary fields
ritmGR.insert();
});
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning āā
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 05:33 AM
Thanks For Reply
How to call Business rule in Workflow Can I create Script include for using same code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 05:50 AM
Script include requires additional steps and information that can be passed further and call from workflows or business rules later
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-10-2024 05:48 AM
Hi @vishalAg20
You cannot call business rules in workflow directly. You can achieve the effect of reusing the logic in both contexts Workflows(workflow scripts) by encapsulating the logic within a Script Include.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning āā
Thanks & Regards
Deepak Sharma