Marygolds3
09/11/2020, 5:48 PMSandii
09/11/2020, 5:49 PMMarygolds3
09/11/2020, 5:50 PMvar approvalList = objRecord.getValue({fieldId:'custrecord7'});
log.debug('afterSubmit','approvalList =='+approvalList);
var approvalListId = [];
for(var i = 0; i < approvalList.length; i++)
{
approvalListId.push(approvalList[i]);
log.debug('afterSubmit','approvalListId =='+approvalListId);erictgrubaugh
09/11/2020, 5:51 PMapprovalList?Marygolds3
09/11/2020, 5:51 PMerictgrubaugh
09/11/2020, 5:51 PMcustrecord7Marygolds3
09/11/2020, 5:51 PMMarygolds3
09/11/2020, 5:51 PMMarygolds3
09/11/2020, 5:52 PMMarygolds3
09/11/2020, 5:53 PMMarygolds3
09/11/2020, 5:53 PM_nikhilpalli
09/11/2020, 5:54 PMlog.debug('details',{
value:approvalList,
type:typeof approvalList
});_nikhilpalli
09/11/2020, 5:54 PMSandii
09/11/2020, 5:55 PMMarygolds3
09/11/2020, 5:55 PMMarygolds3
09/11/2020, 5:57 PMMarygolds3
09/11/2020, 5:57 PMMarygolds3
09/11/2020, 5:57 PMMarygolds3
09/11/2020, 5:57 PMMarygolds3
09/11/2020, 5:57 PM_nikhilpalli
09/11/2020, 5:58 PMtypeof approvalList and tell us the valueSandii
09/11/2020, 5:59 PMerictgrubaugh
09/11/2020, 5:59 PMfor loop in the first place? Assuming getValue() is returning an Array of two values, you're just making a copy of that Arrayerictgrubaugh
09/11/2020, 6:00 PMgetValue() isn't returning an Array, then a for loop won't workerictgrubaugh
09/11/2020, 6:01 PMtypeof approvalList as suggested previously, and log its length as wellstalbert
09/11/2020, 6:01 PMfor loopserictgrubaugh
09/11/2020, 6:01 PMerictgrubaugh
09/11/2020, 6:02 PMlog.debug("approvalList", approvalList) will be clearerMarygolds3
09/11/2020, 6:11 PMMarygolds3
09/11/2020, 6:11 PMMarygolds3
09/11/2020, 6:12 PMMarygolds3
09/11/2020, 6:13 PMerictgrubaugh
09/11/2020, 6:13 PMfor loop to work as intended, getValue() must return an Array of values. And if it's already returning an Array of values, there's no need for you to iterate and make a new Array.erictgrubaugh
09/11/2020, 6:14 PMfor loop to make sure you have an Array of values; generally that means it's returning a string that you need to split(). That's why we're advising you log the typeofjen
09/11/2020, 6:23 PMapprovalList is probably a comma separated string, not an array. You probably want something like this:jen
09/11/2020, 6:23 PMvar approval_list = objRecord.getValue({fieldId:'custrecord7'}).split(',');
for(var i = 0; i < approval_list.length; i++) {
// Do whatever you need to do with each of the elements.
var approval_list_id = approval_list.length[i].trim();
log.debug({title: 'afterSubmit()', details: 'Currently doing things with ' + approval_list_id});
}jen
09/11/2020, 6:23 PMMarygolds3
09/11/2020, 6:49 PMMarygolds3
09/11/2020, 6:50 PMMarygolds3
09/11/2020, 6:51 PMMarygolds3
09/11/2020, 6:52 PMMarygolds3
09/11/2020, 6:52 PMMarygolds3
09/11/2020, 6:52 PMjen
09/11/2020, 6:53 PMjen
09/11/2020, 6:54 PMMarygolds3
09/11/2020, 7:05 PMerictgrubaugh
09/11/2020, 7:07 PMerictgrubaugh
09/11/2020, 7:07 PMtypeof would tell you very clearly. Alternatively, use the util module's typechecking methodsMarygolds3
09/11/2020, 7:13 PMMarygolds3
09/11/2020, 7:13 PMMarygolds3
09/11/2020, 7:14 PMMarygolds3
09/11/2020, 7:14 PMMarygolds3
09/11/2020, 8:03 PMMarygolds3
09/11/2020, 8:04 PMMarygolds3
09/11/2020, 8:05 PMMarygolds3
09/11/2020, 9:16 PM