Populate Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 08:04 AM
The prcoess is when we create a request on one catalog item that will automatically create a new request in another catalog item and this was achieved with the help of Flow Designer. But the location field (user selected) from one catalog item is not populating to location field in anothe request item in another catalog item.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 07:39 AM
Hello @Dileep2
You can achieve this requirement by 2 methods.
Method1:
Business Rule Method
Use this method if the action is tied to specific RITMs or runs automatically based on an event.
Steps:
Navigate to: System Definition → Business Rules → New.
Configure the Business Rule:
- Name: Populate Location from RITM.
- Table: sc_req_item (Request Item).
- Trigger: After Insert or Update (depending on your need).
(function executeRule(current, gsn) {
// Fetch the source RITM
var sourceRITM = new GlideRecord('sc_req_item');
if (sourceRITM.get('sys_id', '<source_ritm_sys_id>')) { // Replace with source RITM's sys_id or logic
current.location = sourceRITM.location; // Copy location
current.update(); // Save the changes
}
})(current, gsn);
Method2:
Script Include Method
Use this if the logic is reusable across multiple processes or triggered by catalog workflows.
Steps:
Navigate to: System Definition → Script Includes → New.
Script:
var RITMLocationHelper = Class.create();
RITMLocationHelper.prototype = {
initialize: function() {},
copyLocation: function(targetRITMId, sourceRITMId) {
var sourceRITM = new GlideRecord('sc_req_item');
if (sourceRITM.get(sourceRITMId)) {
var targetRITM = new GlideRecord('sc_req_item');
if (targetRITM.get(targetRITMId)) {
targetRITM.location = sourceRITM.location;
targetRITM.update();
return true;
}
}
return false;
},
type: 'RITMLocationHelper'
};
- Invoke the Script Include in your workflow or custom script:
var helper = new RITMLocationHelper();
helper.copyLocation('<target_ritm_sys_id>', '<source_ritm_sys_id>');
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar