Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

array.push[] is not working in workflow approval group

DASAMANDAMS
Tera Contributor

Hi all,

I am trying below code in workflow approval group activity where i want to push group sys_id based on certain condition.

I am getting below error in logs "Cannot find function push in object servicenow".

Can someone help me on this.

 

var answer = [];

 

// Assuming current.variables.oracle_custom_roles contains the data as a string.
var rolesArray = JSON.parse(current.variables.oracle_custom_roles.toString());

 

// Loop through each item in the rolesArray
for (var i = 0; i < rolesArray.length; i++) {
    var businessFlow = rolesArray[i].business_flow.toString();  // Extract the business_flow value

    // Check if the business_flow is 'P2P'
    if (businessFlow == 'P2P') {
        answer. Push('31ea3d7e1b7b8e582be1eac82d4bcb09');  // Push specific value to answer array
    }
if (businessFlow == 'R2P') {
    answer. Push('31ea3d7e1b7b8e582be1eac82d4bcb09');  // Push specific value to answer array
    }
}
}

1 REPLY 1

Zach Koch
Giga Sage

it needs to be 

answer.push('31ea3d7e1b7b8e582be1eac82d4bcb09')

No space after the . and push needs to be lowercase, not Push