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

Question

Question

Forms - My Current Step field is not working after the first step in the process

asked on March 24, 2021 Show version history

I setup a Current Step field for use with field rules that run based on the step the process is in.

I set the default value

I capture the value in jquery with

let step = $('.CurrentStep input').val();

I post it into an output field with this including the change to communicate with field rules

 $('.CurrentStepOutput input').val(step).change();

I setup the field rule to hide and remove the data when the output field is populated, preparing the input field to receive the default value again.

When I start the process I see the step name in the output

I see the console log of the original value received from Forms, used to copy to the output field.

When I open the form on the next step both fields are showing and are blank.

The console log is blank showing the Forms never provided the value.

This was working, I don't think I am missing anything in the requirements to read the current step name.

 

0 0

Answer

SELECTED ANSWER
replied on March 24, 2021

Here's how a Laserfiche employee recommended I set up processes to get the current step name.  I've used this successfully on dozens of forms for a lot of different purposes.

Populate the current step value into a Custom HTML element by setting the value of the field to "{/_current_step_name}", and give it a Class name like: getCurrentStepName.  Then your Javascript can retrieve that step name like this:     $('.getCurrentStepName').text()

Because it is a Custom HTML element instead of a field, you never have to work to clear it out and repopulate it each time, it just does it automatically.

2 0
replied on March 24, 2021 Show version history

This works! The HTML field type is not available as a field rule condition making it a really odd field to use for process related variables, but I can use javascript to copy it back to a standard field and finally get my field rules working again.

Not sure why variables are so hard to access with field rules, I can't even think of where everyone is using these variables outside of field rules.

Thank you!

1 0
replied on March 24, 2021

Yeah, it would be nice if the Step Name was available in Field rules.

I use the Step Name a lot directly in Javascript for things like alternate handling of a field based on the part of the process where the form exists, and for adding notes about the actions a user took on a form.

0 0
replied on March 25, 2021

Running into something odd trying this method. Everything works through the process until I call a Save to Repository Task. Somehow the variable switches back to the word "Start" while the form is being archived. So the final archive looks like the starting form.

I could see it sticking with the last step name, since archive may not update the variable to the name of the archive step, but how in the world is it switching back to "Start"??

0 0
replied on March 25, 2021

For you STR task, do you have it set to "Save a form from a previous step" or "Save a form using existing data"? If you are saving a specific form from a previous step, it would save that form as submitted with "Start".

0 0
replied on March 25, 2021 Show version history

I had it as Save a form from a previous step (Start), but I switched it to Save a specific form (Starting Form) and the step name is still reverted to Start in the archive. This is using the HTML Element method of showing the variable. I can see the HTML box because it is not hidden and it clearly says "Start".

I think the only workaround at this point would be to have more javascript that looks for the last user task and fills another field called "Archive Next" with "Yes" which is included in the field rules to make sure everything is showing.

What I am trying to do is very basic, it is an insurance form which requires being filled out partially and signed by a hire, then internally completed by staff.

So I need to show the hire fields and signatures on Start, show the internal fields and hide the signatures on user tasks, and in the archive I want to show everything.

I know LF Forms is designed so that no one should ever touch a form already signed, but I can't tell you how many forms in the industry work like this. It is not something we can change, they REQUIRE this capability.

0 0
replied on March 25, 2021

Personally, I keep the Custom HTML element hidden, and if I need to retain what the value was at a specific point, I use Javascript to populate that into a regular form field that is displayed.

The archival of the form is going to regenerate the form, and with the Custom HTML element working the way it does, it's going to display a new value there at that time, unrelated to any prior user tasks.

0 0
replied on March 25, 2021

That would be ok, but not sure why it is changing to "Start" during the archive

0 0
replied on March 25, 2021

Probably just a default value - it's trying to populate that display based on the name of a user task, but it's an archival task instead, so there isn't a value to show at that time.

0 0
replied on March 25, 2021

I did find that changing the form to save with current process data, if starting a brand new process (for some reason the existing tasks did not change) changed the outcome. It changes the archive step to be a blank value, however the value in the HTML box stops getting copied over to the CurrentStepOutput field (which is illogical since it does work when I switch back to the old archive method).

There is some strange stuff going on in archive. In the past I did not have signatures on the forms, so it was easier to get the rules working with "does not contain". But now I need to know exactly when we are archiving so I can re-apply the signature data.

I feel like what I am trying to do is simple. Show section 1 on start, hide signatures and append section 2 on user task, show signatures and all sections on archive.

0 0
replied on March 25, 2021

You probably already know this part - but just in case: The archive step should basically the same as setting a form to be read-only (or viewing a prior submission within forms).  The layout will have major differences (things like using div elements instead of input/select/textarea elements).  That has major impacts on how your Javascript processes, particularly any code that is relying on things like the input/select/textarea elements.

How that applies to the Custom HTML element with the "{/_current_step_name}" value: the element is going to try to display whatever step name exists for the Archive task, not the prior user task or anything like that, there might not even be a value at the time, which may be why it says "Start" or is left blank.

How I would recommend using that to operate: During the user task, you should be able to copy the value from the Custom HTML field into a regular input field, and build your Field Rules based on that field.  If you've done the Javascript referencing the input element of the regular field, then your Javascript won't try to do the update at the time of the Archive simply because the input element doesn't exist, so then your Field Rules would still follow whatever value was populated into the input field on the last user task.  If you are wanting a completely different appearance on your form during the archive step than you see in any of the user steps, then you'd probably have an easier time making a copy of your existing form, and tweaking it slightly for how you want it to appear in the Archival, and just use that form for the archival and the original form for the user task(s).

0 0

Replies

replied on March 24, 2021

Why not just use a hidden field with a default value {/_current_step_name}. In your field rule, have the field hide always and ignore data on submit. That value will be updated with the current step each way and can be used for field rules. 

0 0
replied on March 24, 2021 Show version history

I have tried to go with simpler routes in the past and was led to believe this is the only way to get the step name.

So I just tried that, which would be nice, but it does not work after the first step. I can tell in 2 ways, by opening the task and not finding the section I chose to show, and because Javascript can still pull and log what is provided by Forms even when I hide always.

My javascript is successfully pulling the text "Start" from the hidden field on the starting step and every step after is blank.

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

Sign in to reply to this post.