Unable to see my gs.info or gs.log in logs table in servicenow

VIKAS MISHRA
Tera Contributor

I have done one integration with third party tool thorugh rest message integration so that it will send some fields updates to third party tool.

Below is my script include code in which i am using code at last gs.info(responseBody); and gs.info(httpStatus);, just to check what actually its containing in body and what is the status, but its not generation any log in logs table, please suggest if i am doing somthing wrong.

I have tries gs.log also, but no go. 

 

Script inculde code below:

 

sendSbDataToConga: function() {
        try {
            var sbRecord = [];
            //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();

            //info["Total Number of Records"] = recordCount;

            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();
                sbRecJson.isUsBankImpacting = sbReq.x_amex_sr_pu_bank_impacting.toString();

                //             sbRecJson.onboardingBuTrmName = sbReq.x_amex_sr_bu_trm_name.getDisplayValue().toString();
                //             sbRecJson.onboardingBuTrmEmailAddress = sbReq.x_amex_sr_bu_trm_email_address.toString();
                //             sbRecJson.onboardingBuL4 = sbReq.x_amex_sr_business_unit_level_4.getDisplayValue().toString();
                //             sbRecJson.onboardingBuTrmLeader = sbReq.x_amex_sr_bia_trm_lead.getDisplayValue().toString();
                //             sbRecJson.countryTo = sbReq.x_amex_sr_location_of_services_to.getDisplayValue().toString();
                //             sbRecJson.countryFrom = sbReq.x_amex_sr_location_of_services_from.getDisplayValue().toString();
                //             sbRecJson.TlmID = sbReq.x_amex_sr_associated_tlm_id.toString();
                //             sbRecJson.bankImpacting = sbReq.x_amex_sr_pu_bank_impacting.toString();

                sbRecord.push(sbRecJson);
                //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();

            }
            //response = info;
            response.data = sbRecord;
            gs.info(JSON.stringify(sbRecord));
            // gs.info('VM depts-received ' + recordCount);
            var dept_data = JSON.stringify(response);
            // gs.info("VM dept_data" + dept_data.replace(/\\"/g, '\\"'));
            //return dept_data.replace(/\\"/g, '\\"');

            var r = new sn_ws.RESTMessageV2('x_amex_sr.Conga Integration', 'post_Data_SB_to_Conga1');
            r.setStringParameterNoEscape('access_token', this.generateRefreshToken());
            r.setRequestBody(sbRecord);
            var response1 = r.execute();
            var responseBody = response1.getBody();
            var httpStatus = response1.getStatusCode();
            
            gs.info(responseBody);
            gs.info(httpStatus);


        } catch (ex) {
            var message = ex.message;
        }
    },

8 REPLIES 8

Cris P
Tera Guru

Can you try gs.info('Vikas ' + responseBody);

 

Then in the logs search for Message starting with 'Vikas'

 

If nothing shows up then are you sure the script include is being invoked?

 

Another thing to check: Perhaps your try/catch is catching an error?

Tried it, but have not got any logs starting with vikas, its actually not generation the logs for this 

If you put a log in the 'catch' block do you get an output?

 

If you put a log right at the top of your method (outside the try/catch), do you get any output?

Yes its showing me the log if add it in Catch block and on the top of Try catch i mean outside of it on the top.