- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:04 AM
I am doing one rest message integartion , for which i have created script incude, in the script inculde i have bold the 2 line of code, the first code which is bold is working fine but due to second bold code i am getting error "Cannot find function split in object 90237e60db5df410d6a11c9468961995 00000288.0." , Why the second bold code is not working but first one is working fine.
this.setCongaPushFieldTrue(sbRecordSysIds, response.getStatusCode(), JSON.parse(response.getBody()));
setCongaPushFieldTrue: function(sbRecordSysIds, httpStatus, responseBody) {
//sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
if (httpStatus != '200') {
var sbR = sbRecordSysIds.split(",");
for (var a = sbR[0]; a <= sbR.length; a++) { //a=sysid1 contract1
var gr = new GlideRecord('x_amex_sourcing_request_request');
gr.addQuery('sys_id', a.split(' ')[0]);
gr.query();
if (gr.next()) {
gr.x_amex_sr_ready_for_conga_push = true;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
}
else if (httpStatus == '200'){
// responseBody = [{"isSuccess":false,"errorMessage":"Agreement: 00000288.0 is not present in Conga","apttus_contract_id":"00000288.0"},{"isSuccess":true,"errorMessage":"","apttus_contract_id":"00006475.0"}];
// sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
gs.info('enters in else if loop');
for(var i in responseBody){
var flag = responseBody[i].isSuccess;
if(!flag){
var ContId = responseBody[i].apttus_contract_id;
gs.info('testing response For True/False ' + ContId + " " + flag);
var sbR1 = sbRecordSysIds.split(",");
gs.info('testing1' + sbR1);
for (var b = sbR1[0]; b <= sbR1.length; b++){
gs.info('testing2');
var gr1 = new GlideRecord('x_amex_sourcing_request_request');
gs.info('testing3');
gr1.addQuery('sys_id', a.split(' ')[0]);
gs.info('testing4');
gr1.addQuery('x_amex_sr_contract_id', ContId);
gs.info('testing5');
gr1.query();
if (gr1.next()) {
gr1.x_amex_sr_ready_for_conga_push = true;
gr1.setWorkflow(false);
gr1.autoSysFields(false);
gr1.update();
gs.info('testing6');
}} } }} },
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:27 AM
Hi,
Since this variable is already array, no need to split. Also I see that your for loop has issues. You can use this updated code. Highlighted the changes in bold:
this.setCongaPushFieldTrue(sbRecordSysIds, response.getStatusCode(), JSON.parse(response.getBody()));
setCongaPushFieldTrue: function(sbRecordSysIds, httpStatus, responseBody) {
//sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
if (httpStatus != '200') {
var sbR = sbRecordSysIds;
for (var a = 0; a <= sbR.length; a++) { //a=sysid1 contract1
var gr = new GlideRecord('x_amex_sourcing_request_request');
gr.addQuery('sys_id', sbR[a].split(' ')[0]);
gr.query();
if (gr.next()) {
gr.x_amex_sr_ready_for_conga_push = true;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
}
else if (httpStatus == '200'){
// responseBody = [{"isSuccess":false,"errorMessage":"Agreement: 00000288.0 is not present in Conga","apttus_contract_id":"00000288.0"},{"isSuccess":true,"errorMessage":"","apttus_contract_id":"00006475.0"}];
// sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
gs.info('enters in else if loop');
for(var i in responseBody){
var flag = responseBody[i].isSuccess;
if(!flag){
var ContId = responseBody[i].apttus_contract_id;
gs.info('testing response For True/False ' + ContId + " " + flag);
var sbR1 = sbRecordSysIds;
gs.info('testing1' + sbR1);
for (var b = 0; b <= sbR1.length; b++){
gs.info('testing2');
var gr1 = new GlideRecord('x_amex_sourcing_request_request');
gs.info('testing3');
gr1.addQuery('sys_id', sbR1[b].split(' ')[0]);
gs.info('testing4');
gr1.addQuery('x_amex_sr_contract_id', ContId);
gs.info('testing5');
gr1.query();
if (gr1.next()) {
gr1.x_amex_sr_ready_for_conga_push = true;
gr1.setWorkflow(false);
gr1.autoSysFields(false);
gr1.update();
gs.info('testing6');
}} } }} },
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:09 AM
Hi,
I dont understand your code. The below code is not a valid syntax.
sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
If you want them as string then put them within double quotes like below
sbRecordSysIds = "[sysid1 contract1,sysid2 contract2]";
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:13 AM
I have just given you a peace of code from my script inculde actually the code "sbRecordSysIds = "[sysid1 contract1,sysid2 contract2]"; " is just to show you an example , otherwise in actually variable sbRecordSysIds is having value "90237e60db5df410d6a11c9468961995 00000288.0"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:15 AM
Below is the full code till my function declaration , please check this
var AXP_Apttus_Integration_Utils = Class.create();
AXP_Apttus_Integration_Utils.prototype = {
initialize: function() {},
//Below function is used to update the data to APTTUS from SB record
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 + "");
sbRecordSysIds.push(sbReq.sys_id.toString() + " " + sbRecJson.apttus_contract_id);
gs.info('combination ' + 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();
}
//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, '\\"');
if (recordCount == '0') {
gs.info('record count is ' + recordCount);
return false;
}
var token = this.generateRefreshToken();
var response = this.runRestMsg('post_Data_SB_to_Apttus', token, sbRecord);
this.storeTransactionDetails(sbRecord, response.getBody(), 'Apttus Outbond', recordCount, token, response.getStatusCode());
gs.info("response body " + response.getBody());
gs.info("Status " + response.getStatusCode());
this.setCongaPushFieldTrue(sbRecordSysIds, response.getStatusCode(), JSON.parse(response.getBody()));
} catch (ex) {
var message = ex.message;
gs.info('Test error: ' + ex.message);
}
},
setCongaPushFieldTrue: function(sbRecordSysIds, httpStatus, responseBody) {
//sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
if (httpStatus != '200') {
var sbR = sbRecordSysIds.split(",");
for (var a = sbR[0]; a <= sbR.length; a++) { //a=sysid1 contract1
var gr = new GlideRecord('x_amex_sourcing_request_request');
gr.addQuery('sys_id', a.split(' ')[0]);
gr.query();
if (gr.next()) {
gr.x_amex_sr_ready_for_conga_push = true;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
}
else if (httpStatus == '200'){
// responseBody = [{"isSuccess":false,"errorMessage":"Agreement: 00000288.0 is not present in Conga","apttus_contract_id":"00000288.0"},{"isSuccess":true,"errorMessage":"","apttus_contract_id":"00006475.0"}];
// sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
gs.info('enters in else if loop');
for(var i in responseBody){
var flag = responseBody[i].isSuccess;
if(!flag){
var ContId = responseBody[i].apttus_contract_id;
gs.info('testing response For True/False ' + ContId + " " + flag);
var sbR1 = sbRecordSysIds.split(",");
gs.info('testing1' + sbR1);
for (var b = sbR1[0]; b <= sbR1.length; b++){
gs.info('testing2');
var gr1 = new GlideRecord('x_amex_sourcing_request_request');
gs.info('testing3');
gr1.addQuery('sys_id', a.split(' ')[0]);
gs.info('testing4');
gr1.addQuery('x_amex_sr_contract_id', ContId);
gs.info('testing5');
gr1.query();
if (gr1.next()) {
gr1.x_amex_sr_ready_for_conga_push = true;
gr1.setWorkflow(false);
gr1.autoSysFields(false);
gr1.update();
gs.info('testing6');
}
}
}
}
}
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:27 AM
Hi,
Since this variable is already array, no need to split. Also I see that your for loop has issues. You can use this updated code. Highlighted the changes in bold:
this.setCongaPushFieldTrue(sbRecordSysIds, response.getStatusCode(), JSON.parse(response.getBody()));
setCongaPushFieldTrue: function(sbRecordSysIds, httpStatus, responseBody) {
//sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
if (httpStatus != '200') {
var sbR = sbRecordSysIds;
for (var a = 0; a <= sbR.length; a++) { //a=sysid1 contract1
var gr = new GlideRecord('x_amex_sourcing_request_request');
gr.addQuery('sys_id', sbR[a].split(' ')[0]);
gr.query();
if (gr.next()) {
gr.x_amex_sr_ready_for_conga_push = true;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
}
else if (httpStatus == '200'){
// responseBody = [{"isSuccess":false,"errorMessage":"Agreement: 00000288.0 is not present in Conga","apttus_contract_id":"00000288.0"},{"isSuccess":true,"errorMessage":"","apttus_contract_id":"00006475.0"}];
// sbRecordSysIds = [sysid1 contract1,sysid2 contract2]
gs.info('enters in else if loop');
for(var i in responseBody){
var flag = responseBody[i].isSuccess;
if(!flag){
var ContId = responseBody[i].apttus_contract_id;
gs.info('testing response For True/False ' + ContId + " " + flag);
var sbR1 = sbRecordSysIds;
gs.info('testing1' + sbR1);
for (var b = 0; b <= sbR1.length; b++){
gs.info('testing2');
var gr1 = new GlideRecord('x_amex_sourcing_request_request');
gs.info('testing3');
gr1.addQuery('sys_id', sbR1[b].split(' ')[0]);
gs.info('testing4');
gr1.addQuery('x_amex_sr_contract_id', ContId);
gs.info('testing5');
gr1.query();
if (gr1.next()) {
gr1.x_amex_sr_ready_for_conga_push = true;
gr1.setWorkflow(false);
gr1.autoSysFields(false);
gr1.update();
gs.info('testing6');
}} } }} },
Palani