You are viewing limited content. For full access, please sign in.

Question

Question

Require Status to be closed before form can be submitted

asked on June 6, 2017

I have a form with a field for status, where status can be open or closed.  The form goes to a review user task.  How do I configure it so that the status must be closed before it can be submitted from that point?  I have tried setting up an exclusive gateway that routes the form back to review if status = open, but note that it does not add anything to the history to explain what it was routed back.  Thanks in advance for any help!

 

- Alon

0 0

Answer

SELECTED ANSWER
replied on June 29, 2017 Show version history

Rui,

 

Thanks so much for all of your help!  Just a few notes for anyone who references this in the future:  I made the change from closed to Closed and set the CSS class of the Status field to status.  This is the code:

$(document).ready(function(){
  if ($('[name=IsLocked]').val() == 'False') {
  	$('.status select').change(checkStatus);
  	checkStatus();
  }
})
function checkStatus()
{
  if ($('.status select').val() == 'Closed') {
    $('.Submit').prop('disabled',false);
  }
  else {
    $('.Submit').prop('disabled',true);
  }
}

Where the field being checked is Status, it is looking for the value Closed, and the button being disabled is Submit

0 0

Replies

replied on June 6, 2017

If you just want to force the field to have value "closed", you can use a single line field and set "closed" as regular expression for validation;

If you want to route back if it's not "closed", and want to keep a history for it, what about adding two user tasks? If status=open, then route to the second task and set task name explaining the reason. And keep routing to the second task afterwards.

0 0
replied on June 19, 2017

Rui,

I want to route it back if not closed, the second task idea would work, but has the fairly significant drawback of adding a second task for user to have to look in.  It would be preferable to route it back to the original task with meaningful history or some other 'flag' to let them know why it was routed back?

 

Alon

0 0
replied on June 19, 2017

Maybe you can force the user to fill comment with meaningful reason, since the comment would show on action history.

Mark comment box required like https://answers.laserfiche.com/questions/117970/making-comments-box-required-in-Forms-with-javascript

Or, fill comment box automatically by javascript if the status is open/changed to open.

0 0
replied on June 20, 2017

Thanks Rui, do you have an example of the javascript I would use?  Is there a way to use CSS or java script to just disable the submit button if the Status is not set to closed?

0 0
replied on June 20, 2017

What kind of field the Status field is? Here is a demo for single line field (set css class 'status'):

$(document).ready(function(){
  if ($('[name=IsLocked]').val() == 'False') {
  	$('.status input').change(checkStatus);
  	checkStatus();
  }
})
function checkStatus()
{
  if ($('.status input').val() == 'closed') {
    $('.Submit').prop('disabled',false);
  }
  else {
    $('.Submit').prop('disabled',true);
  }
}

 

0 0
replied on June 27, 2017

Sorry for the delayed response Rui, this looks great!  In my case the field is named Status and is a dropdown.

0 0
replied on June 27, 2017

For dropdown, change input to select like this:

$(document).ready(function(){
  if ($('[name=IsLocked]').val() == 'False') {
  	$('.status select').change(checkStatus);
  	checkStatus();
  }
})
function checkStatus()
{
  if ($('.status select').val() == 'closed') {
    $('.Submit').prop('disabled',false);
  }
  else {
    $('.Submit').prop('disabled',true);
  }
}

 

0 0
replied on June 28, 2017

Thanks Rui!  But I can't seem to get it to work, once I put the code in the Submit button is always disabled regardless of the Status value.  Here are some screenshots of the code I put in and the Status field details.  I thought maybe there was some case sensitive things going on so tried changing status to Status and closed to Closed in the code, but that didn't help either.

 

0 0
replied on June 28, 2017

The value your field used is "Closed" but in the script it expects "closed". Change $('.status select').val() == 'closed' to $('.status select').val() == 'Closed' should work. Also make sure CSS class has been set on the field.

0 0
SELECTED ANSWER
replied on June 29, 2017 Show version history

Rui,

 

Thanks so much for all of your help!  Just a few notes for anyone who references this in the future:  I made the change from closed to Closed and set the CSS class of the Status field to status.  This is the code:

$(document).ready(function(){
  if ($('[name=IsLocked]').val() == 'False') {
  	$('.status select').change(checkStatus);
  	checkStatus();
  }
})
function checkStatus()
{
  if ($('.status select').val() == 'Closed') {
    $('.Submit').prop('disabled',false);
  }
  else {
    $('.Submit').prop('disabled',true);
  }
}

Where the field being checked is Status, it is looking for the value Closed, and the button being disabled is Submit

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.