I am trying to get a form to assign a Next Step based on the user that completed the last step. I have a single line field that fills with current user, which works for the first step, but further down the process, I need that field to refill with the new current user. It doesn't. Is there a way for force it to reload the current user each time the form is opened?
Question
Question
Current User in single line field is not changing upon next task.
Replies
Hi Connie,
The default field values will only be used if the field doesn't already contain a value. When you submit the first form, the first user's name is stored in that variable and when the next task is loaded this variable value takes precedence over the default value. Unfortunately there's no way to force this to behave differently.
The way I have done this previously is to have a table were a new line is added automatically for each task, so it effectively keeps a list of all participants on the form, however I don't think that will work for your use case.
If you're trying to dynamically assign the next task based on the user who completed the previous task, you could try using a team filter. More can be found on these here.
Hope this helps!
Dan
Okay, thanks Daniel. What about this? ... I sometimes use this JavaScript to always clear a drop-down field each time the form is loaded, but I've never used it on a single line field. What would I change in the JS in order to use it for clearing out this sl field?
//clears the target control box upon reload//
$(document).ready(function() {
$('.alwaysclear select').val('');
});
Hi Connie,
The default values are only entered in the field on form load, so clearing the value using JavaScript after the form has loaded would just result in the field being blank unfortunately.
I think your best bet is probably to try using something in the process modeller to make the routing decision, rather than trying to update the form variable if it's at all possible. If you can post a screenshot of your process and what you're trying to achieve we might be able to give you some suggestions
Cheers,
Dan
Its just a simple purchase order progress monitoring process. Only one user is using it for now so I can hard-code it to her, however, I was trying to make the process a little more flexible if others begin using it, or taking over for her.
I can hard-code it to her.
I can set it to assign to initiator. I think this might be the best alternative.
Thanks, Daniel. Even just understanding why the other options aren't working is very helpful!
I do something similar on a lot of forms via Javascript.
Add a custom HTML element to your form, and put nothing it it other than this: {/_currentuser}
You can alternately use {/_currentuser_display} if you want display name instead of username.
Give the custom HTML element a class name like this: getCurrentUser
Add a Single-Line element with a class name like like: setCurrentUser
Add CSS to always hide the field from view:
.getCurrentUser {display: none!important;}
Now you can add Javascript that populates the single-line field with the text from the custom HTML element:
$(document).ready(function () { //Make the field read-only. This is done via Javascript //instead of the layout page, to ensure the Javascript //can populate the field and have the value saved. $('.setCurrentUser input').attr('readonly', 'true'); //Populate the setCurrentUser field with the current user $('.setCurrentUser input').val($('.getCurrentUser').text()); });
Awesome! Thank you, Matthew! I haven't had a chance to go back to the original form and try this there, however, I got a request from someone today and it required creating a report on a specific Instance ID# but for some reason, I couldn't get the form to save the ID# into a hidden field so ... I remembered you had provided me with this and altered the info for use in collecting the ID number instead. It worked! I was able to provide the report setup with a filter for one specific ID # and it worked perfectly! Thanks again!
That's fantastic!
Hello Matthew,
Please can you provide a step-wise guide on how to give an element a class name?
Sound so simple but i have no clue
Also, must it be an html field that must be used?
Both with the Classic Designer and the Modern Designer, you add class names to fields (any of the fields) from the layout page. When you select the field, and tab to the advanced settings of the field, you can add the class name(s) there. On the modern designer it is a functionality to "click + to add another class name", and on the classic designer you add more than 1 by separating them with a space.
Note that the Javascript here is written for the Classic Designer and won't work in the Modern Designer without some modifications.