Populate Location

Dileep2
Tera Contributor

HI All,

 

Please check the screenshot, how to populate the location field from one catalog item to another catalog item.

 

Thank you

3 REPLIES 3

Runjay Patel
Giga Sage

Hi @Dileep2 ,

 

What is your scenario to populate it?

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

Juhi Poddar
Kilo Patron

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:

  1. Navigate to: System Definition → Business Rules → New.

  2. 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:

  1. Navigate to: System Definition → Script Includes → New.

  2. 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