Tanushree Maiti
Tera Patron

Hi @MaheshG95462175 

 

Try this:

 

1: Create a Client-Callable Script Include

  • Name: RemoteTableUtils
  • Client callable: Checked (True)

 

var RemoteTable = Class.create();

RemoteTable.prototype = Object.extendsObject(AbstractScriptProcessor, {

 

    getRemoteDescription: function() {

        var recordId = this.getParameter('sysparm_record_id');

        if (!recordId) return '';

        var gr = new GlideRecord('u_your_remote_table_name'); // Replace with your actual Remote Table API name

        if (gr.get(recordId)) {

            return gr.getValue('u_description'); // Replace with your actual Description field name

        }

        return '';

    },

    type: 'RemoteTable'

});

 

 2: Create an onChange Catalog Client Script

  • Applies to: Catalog Item
  • Type: onChange
  • Variable name: Select your Reference variable

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue === '') {

        return;

    }

    var ga = new GlideAjax('RemoteTable');

    ga.addParam('sysparm_name', 'getRemoteDescription');

    ga.addParam('sysparm_record_id', newValue);

    ga.getXMLAnswer(parseAndPopulate);

}

 

function parseAndPopulate(response) {

    var description = response;   

    if (description) {

        try {

            var parsedData = JSON.parse(description);

            g_form.setValue('your_target_variable_name', parsedData.targetValue);

        } catch (e) {

              if (description.indexOf('Code:') > -1) {

                var extractedValue = description.split('Code:')[1].trim();

                g_form.setValue('your_target_variable_name', extractedValue);

            } else {

                g_form.setValue('your_target_variable_name', description);

            }

        }

    }

}

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti