How to push 2 different field's value in an combination in one array.

VIKAS MISHRA
Tera Contributor

Kindly see the below code which i have written in script inculde which is used to send 8 different fields data to thrd party tool, basically i am doing rest integration to send the data to third party tool.

Now in the below code till now i am saving the sys ids of all the records in the array "sbRecordSysIds"  and in the table "x_amex_sourcing_request_request" there is one field "Contract ID"  so this time i want to save the sys id with the combination of contract id eveytime and save it in the same array "sbRecordSysIds".

Is it possible to save sys id of the record with combination of contract id and push it in the array.

 

sendSbDataToApttus: function() {
        try {
            var sbRecord = [];
            var sbRecordSysIds = [];
            //var info = {};
            // var response = {};

            var sbReq = new GlideRecord('x_amex_sourcing_request_request');
            sbReq.addEncodedQuery('x_amex_sr_ready_for_conga_push=true');
            sbReq.query();
            var recordCount = sbReq.getRowCount();

            while (sbReq.next()) {

                var sbRecJson = {};

                sbRecJson.apttus_contract_id = sbReq.x_amex_sr_contract_id.toString();
                sbRecJson.trm_emailId = sbReq.x_amex_sr_bu_trm_email_address.toString();
                sbRecJson.bu_level1 = sbReq.x_amex_sr_business_unit_level_4.u_level_1.getDisplayValue().toString();
                sbRecJson.bu_level2 = sbReq.x_amex_sr_business_unit_level_4.u_level_2.getDisplayValue().toString();
                sbRecJson.bu_level3 = sbReq.x_amex_sr_business_unit_level_4.u_level_3.getDisplayValue().toString();
                sbRecJson.bu_level4 = sbReq.x_amex_sr_business_unit_level_4.getDisplayValue().toString();
                sbRecJson.countries_to = sbReq.x_amex_sr_location_of_services_to.getDisplayValue().toString();
                sbRecJson.countries_from = sbReq.x_amex_sr_location_of_services_from.getDisplayValue().toString();
                sbRecJson.tlm_Id = sbReq.x_amex_sr_associated_tlm_id.toString();
                if (sbReq.x_amex_sr_pu_bank_impacting.toString().toLowerCase() == 'yes') {
                    sbRecJson.isUsBankImpacting = true;
                } else {
                    sbRecJson.isUsBankImpacting = false;
                }

                sbRecord.push(sbRecJson);
                sbRecordSysIds.push(sbReq.sys_id + "");
                gs.info(sbRecordSysIds);
                //To make ready_for_conga_push false after sending to Conga
                sbReq.x_amex_sr_ready_for_conga_push = false;
                sbReq.setWorkflow(false);
                sbReq.autoSysFields(false);
                sbReq.update();

            }

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Hi,

 

Did you try the below

 sbRecordSysIds.push(sbReq.sys_id.toString() + " " + sbRecJson.apttus_contract_id);

 

If you want to store it in nested array then you can try below.

var tempArr = [];

tempArr.push(sbReq.sys_id.toString());

tempArr.push(sbRecJson.apttus_contract_id);

 sbRecordSysIds.push(tempArr);

View solution in original post

1 REPLY 1

Muhammad Khan
Mega Sage
Mega Sage

Hi,

 

Did you try the below

 sbRecordSysIds.push(sbReq.sys_id.toString() + " " + sbRecJson.apttus_contract_id);

 

If you want to store it in nested array then you can try below.

var tempArr = [];

tempArr.push(sbReq.sys_id.toString());

tempArr.push(sbRecJson.apttus_contract_id);

 sbRecordSysIds.push(tempArr);