- 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 07:09 AM
It worked , thank you so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 06:13 AM
Hi,
I propose the adjusted version:
sbRecordSysIds = "sysid1 contract1,sysid2 contract2";
Please also check the function parameter if its type is String and it is not null.
Best Regards,
Marcin