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

Question

Question

Form sections available based off user task

asked on May 4, 2022

Not sure if I'm asking this correctly, but is it possible to have one main form for a process instead of multiple, but only allow certain sections to show or be editable based off which user task the process is on?

 

Thanks

0 0

Answer

SELECTED ANSWER
replied on May 4, 2022 Show version history

I'm doing something similar on several forms.  It takes a couple moving parts to get working.

Add a custom HTML element on your form - for the text within it, just list:   {/_current_step_name}   And give it a CSS Class name like:   getCurrentStepName.  If you were to do this with a single-line field, it would only populate the step name on the first use of the form.  But a Custom HTML element cannot save it's value, so it'll re-populate every time the form is loaded.  The downside is you are not going to be able to trigger Field Rules or Data Lookups directly from this field.

To get around that, add a single-line field on your form - leave it editable, and give it the class name of:   setCurrentStepName.

Now add this CSS to your form to always hide the view of the two fields: 

.getCurrentStepName {display: none!important;}
.setCurrentStepName {display: none!important;}

 

Now add some Javascript that when the form is first loaded, will copy the value from the custom HTML element into the single-line element and trigger that it has changed.

$(document).ready(function () {

  //When the form loads, copy the step name into the single-line field,
  //so that it can be used for Field Rules and Lookup Rules.
  $('.setCurrentStepName input').val($('.getCurrentStepName').text()).trigger('change');

});

 

This results in the setCurrentStepName field getting updated with the task name each time the form is loaded, and it recognizes that the field has been changed, so any rules in the Field Rules or Lookup Rules that are triggered from that field will be enacted.

1 0
replied on May 4, 2022

Hi Matthew,

The way I usually get around the form storing the value from a Single Line field is to have a Field Rule set to always Hide and Ignore the data.

That way the form will populate with the default value so it can be used in Field Rules and everything, however, it won't save it so it will change on the next step.

0 0
replied on May 4, 2022

Oh haha, that's a smart idea.

I have some other Javascript that does some other stuff with the step name, so it just made sense to me to handle it entirely within the Javascript, so I always have - but I love to see a no-code solution, and this should work well for @████████ 's situation since there isn't any indicated need to do anything else with the value in Javascript.

Thanks for pointing that out @████████!

0 0

Replies

replied on May 4, 2022

This is awesome.  Thanks for the quick reply.  Can't wait to give this a shot.

1 0
replied on May 4, 2022

You're welcome.  Hopefully it works well for your needs.

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

Sign in to reply to this post.