The CreatorCon Call for Content is officially open! Get started here.

How to send Multirow variableset data from one instance to another E-boning

shashanksha
Tera Contributor

How to send Multirow variable set variables data from one servicenow instance to another servicenow instacne through E-bonding through flow designer payload in servicwnow.

 

I am having a form which have multirow varible set , while entering the data on varibale , how to send the data to another servicenow instacne E-bonding I am uing Flow designer and using action and creating payload to send data using script include

 

shashanksha_1-1760629414286.png

 

 

shashanksha_0-1760629335941.png

 

9 REPLIES 9

@shashanksha 

I shared updated code and commented some code

var Window365SupportRequestGPCPayload = Class.create();
Window365SupportRequestGPCPayload.prototype = {
    initialize: function() {},
    createRequestPayload: function(request_sysid) {
        var requestRec = new GlideRecord('sc_request');


        // Check if the request exists
        if (!requestRec.get(request_sysid)) {
            gs.error('Request not found: ' + request_sysid);
            return {};
        }


        // Fetch associated Requested Item (RITM)
        var ritmRec = new GlideRecord('sc_req_item');
        ritmRec.addQuery('request', request_sysid);
        ritmRec.orderBy('sys_created_on'); // Ensures first RITM is picked if multiple exist
        ritmRec.query();


        if (!ritmRec.next()) {
            gs.error('No Requested Item found for Request: ' + request_sysid);
            return {};
        }


        // Fetch variables from the Requested Item
        var variables = {};

		// no need of below lines as you can directly grab the MRVS JSON
		/*
        var mrvsData = [];
        var gr = new GlideRecord('sc_multi_row_question_answer');
        gr.addQuery('parent_id', ritmRec.sys_id);
        gr.query();
        while (gr.next()) {
            mrvsData.push({
                destination_address_aag: gr.value.toString(),
                service_port_aag: gr.value.toString(),
                purpose_of_this_rule_aag: gr.value.toString(),
            });
        }
        var payload = {
            ritm: ritmRec.number.toString(),
            mrvs: mrvsData,
        };
		*/


        variables.network_connectivity_aag = JSON.stringify(ritmRec.variables.mrvsVariableSetName); // give mrvs set variable name here
        gs.info("test payload " + variables.network_connectivity_aag);

        // Single Line Text
        //added by me
        variables.what_type_of_issue_are_you_having = ritmRec.variables.what_type_of_issue_are_you_having_aag.getValue() || "";
        variables.description = ritmRec.variables.description_aag.getDisplayValue() || "";

        "";
        // Label
        variables.bulk_request = ritmRec.variables.bulk_request_aag.getDisplayValue() || "";


        variables.windows_365_cloud_pc_guides = ritmRec.variables.windows_365_cloud_pc_guides_aag.getDisplayValue() || "";


        //Check box
        variables.have_you_read = ritmRec.variables.have_you_read_aag.getDisplayValue() || "";



        // Final payload
        var requestPayload = {
            sysparm_id: '419475871bf7fd100ab097522a4b', // Target Catalog Item sys_id
            sysparm_quantity: '1', // Quantity set as a top-level key
            variables: {
                related_to_new_W365_application: variables.related_to_new_W365_application,

                what_type_of_issue_are_you_having: variables.what_type_of_issue_are_you_having,
                bulk_request: variables.bulk_request,
                windows_365_cloud_pc_guides: variables.windows_365_cloud_pc_guides,
                have_you_read: variables.have_you_read,


            }
        };


        return requestPayload;
    },



    type: 'Window365SupportRequestGPCPayload'
};

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I commented out that thing and added

 variables.network_connectivity_aag = JSON.stringify(ritmRec.variables.network_connectivity_aag); // give mrvs set variable name here
network_connectivity_aag= this is my multi row varibale set internal name
 
But log payload is coming as empty 
shashanksha_0-1760681601968.png

 

@shashanksha 

print what came in log for this

gs.info(JSON.stringify(ritmRec.variables.network_connectivity_aag));

Also print the complete JSON at the end to verify if it looks fine

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

still it is coming as blank but when i uncomment my code it is coming like this

but it should come {"destination_address_aag":"gpc","service_port_aag":"10.3","purpose_of_this_rule_aag":"test"}

 

shashanksha_0-1760684654252.png

 

shashanksha_1-1760684693332.png

 

var mrvsData = [];
        var gr = new GlideRecord('sc_multi_row_question_answer');
        gr.addQuery('parent_id', ritmRec.sys_id);
        gr.query();
        while (gr.next()) {
            mrvsData.push({
                destination_address_aag: gr.value.toString(),
                service_port_aag: gr.value.toString(),
                purpose_of_this_rule_aag: gr.value.toString(),
            });
        }
        var payload = {
            ritm: ritmRec.number.toString(),
            mrvs: mrvsData,
        };


        variables.network_connectivity_aag = JSON.stringify(mrvsData);

 

 

@shashanksha 

sorry you need to play with the JSON object and then form the JSON string.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader