Trouble Passing an Array Through a Create Event Workflow Activity

Nick Peters
Tera Guru

I'm building an array of user Sys IDs and trying to pass the array as Parameter 1 in a Create Event workflow activity. This triggers an email and then I'm using a mail script in that email to add the array in parm1 as users to be Cc'd.

Unfortunately, the value of parm1 is always ending up as "true" instead of ending up as the array. I'm confirming this in the Event Log as well as by using template.print() in the mail script.

Here is the script that I have in the Parameter 1 field in the workflow activity:

(function() {
	var ccRecipients = [
		current.sysapproval.u_requested_for,
		current.approver.manager
	];
	
	gs.info('Approval Reminder - Cc Recipients: '  + ccRecipients.toString());

	return ccRecipients;
}());

The record being written to the system log with gs.log() above is printing the Sys IDs.

In the Parameter 2 field, I'm just passing a simple string which is working just fine when event.parm2 is called in the email.

I was initially using return ccRecipients.toString() but found in the product documentation that any strings returned as parameters in these activities have to be surrounded with quotes (" ").

Any idea why Parameter 1 is returning "true"?

1 ACCEPTED SOLUTION

Even though the documentation doesn't explicitly state that it has to return a string - only that if it is a string, it needs to be surrounded in quotes - it seems that you're right and it really can only return a string.

I went ahead and just used a Run Script activity and called my event from there and it's working as intended.

View solution in original post

3 REPLIES 3

Mark Stanger
Giga Sage

I think your script (which needs to return a string) looks like it should work.  I do see one potential issue though.  The 'sysapproval' field references the 'task' table.  Unless your 'u_requested_for' field sits on the 'task' table you won't be able to dot-walk to it directly.  What table is your 'u_requested_for' field defined on?

Mark Stanger
Giga Sage

Just checking on on this one.  Has this question been answered or is there more information I can help you with?  If it's been answered, please mark the answer above as the correct one so people know this has been taken care of.  Thanks!

Even though the documentation doesn't explicitly state that it has to return a string - only that if it is a string, it needs to be surrounded in quotes - it seems that you're right and it really can only return a string.

I went ahead and just used a Run Script activity and called my event from there and it's working as intended.