Why is my workflow Approval - User activity "Approval Script" saying "counts" is not defined?

Todd O
Tera Guru

We recently upgraded to Geneva and I have a very odd problem. I'm have a basic workflow that contains a Approval - User activity. Within the activity, I specify the "wait for" dropdown to be condition based on script. Then, within my script I reference a variable called counts (e.g., counts.total, counts.approved, etc). The problem is that I continue to get the below JavaScript exception indicating the "counts" variable is NOT defined. Thank you in advance for anyone that knows the answer. Thanks.

Todd

Todd Activity Approval(ecb4741613e35e000d0879812244b052): Caught exception in InterpretedScript <refname>: org.mozilla.javascript.InterpretedScriptException: Caught exception in InterpretedScript <refname>: org.mozilla.javascript.InterpretedScriptException: Caught exception in InterpretedScript <refname>: org.mozilla.javascript.JavaScriptException: org.mozilla.javascript.WrappedException: WrappedException of "counts" is not defined.

Approval - User Activity in workflow

// Set the variable 'answer' to '', 'approved' or 'rejected' to indicate the approval status for this approval.   When called, the following information is available:

//

//       counts.total = total number of users that are part of this approval

//       counts.approved = # of users that approved so far

//       counts.rejected = # of users that rejected so far

//       counts.requested = # of users that are pending approval

//       counts.not_requested = # of users that are not pending approval

//       counts.not_required = # of users that approval is not required

//

// WHY IS "COUNTS" UNDEFINED!!!! IT SHOULD BE AVAILABLE WITHIN THIS ACTIVITY

gs.addInfoMessage("Counts value from script: " + counts.total);

// temporary code for now while testing...

answer = '';

1 ACCEPTED SOLUTION

Just to document answer, our problem was that someone had changed the out of the box functionality (I think business rule or work flow activity). It's been a while and I don't recall which one. But, tech support reverted to OO box functionality and it started working again.  


View solution in original post

6 REPLIES 6

RP2
Giga Contributor

Where you able to get a solution?



I have scripted the following for 1st reject & majority approval.



gs.log('# Rejected: ' + counts.rejected + ' # Approved:' + counts.approved + ' # Total:' + counts.total);


if(counts.rejected > 0) {


  answer = 'rejected';


}


if(counts.approved/counts.total)*100 > 50) {


answer = 'approved';


}



I am having similar issue Geneva version, upon first approval on Change record


counts.total shows 1


counts.rejected shows 0


counts.approved shows 0


Just to document answer, our problem was that someone had changed the out of the box functionality (I think business rule or work flow activity). It's been a while and I don't recall which one. But, tech support reverted to OO box functionality and it started working again.