I have a process with several forms. The second form in the process is a status form, showing participants where their form is in the approval process. The process has a loop that sends the form back to the employee, if it's denied by AP and sends AP a status form to help them keep track of what's currently outstanding. However, I only want the status form to be sent back to AP if they haven't already been sent one during the process, otherwise, if they reject the same employee's form more than once, they'll have multiple status forms in their queue for the same process.
So, I'm using a field and javascript to implement a counter that increments every time AP gets a status form during the process. The counter starts at 0. The process I created looks to see if the variable associated with the field is set to 0. If it is, AP receives the status form. If the field/variable is great than 0, AP won't receive the status form.
From a logic standpoint, this seems like it should work. However, I'm finding that even though I'm saving the incremented value back to the field, the new field value isn't retained. I can see that it's been set the first time the form is sent to AP. The second and subsequent times the form is sent to AP, the field value remains the same.
Is there something I need to do in javascript to commit the new value to the field? I've included my code below:
$(document).ready(function () {
$('#q192').on('change lookup', changeAPSteps);
function changeAPSteps() {
var isap = $('#q192 input').val();
if ( isap === "yes") {
var apstep = parseNumber($('#q193 input').val());
var sum = apstep + 1;
// increment APStep field value (used for process to determine whether or
// not to send AP a status form (if > 1, don't send status form because they
// already got one)
$('#q193 input').val(sum);
}
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});
Thanks for any help you can give me!