Looking to pass parameter to the JavaScript in Form through URL and then use it to populate field, for example:
http://sample.com/forms/5?test=1
to use test value in JavaScript processes.
Thank you,
Vladimir
Looking to pass parameter to the JavaScript in Form through URL and then use it to populate field, for example:
http://sample.com/forms/5?test=1
to use test value in JavaScript processes.
Thank you,
Vladimir
In the upcoming 9.1 version of Forms, you'll have access to some process variables within the Form Designer, including the process initiator, so you'll be able to set the default value or help text for a field to be the process initiator, current user, etc. Then, you could create a simple page rule based on the initiator or user currently viewing the form. Coupled with the new stored procedure functionality for lookup rules, the new variables in the Form Designer are pretty exciting!
You can create lookup rules that directly use the current user, for example:
However, to hide or show fields based on the current user or process initiator, you'd insert the process initiator or current user variable into a field, and then create a field rule using that field.
In this screenshot you can see the Insert Variable button, and the list of variables you can use as the default value for the field.
You can fill Single Line, Multi-line, Number, and Currency fields (without using JavaScript) by adding parameters to the URL to a form.
In order to do so, you'll need to know the variable name associated with the field you want to fill in, and have the link to that form.Once you have this information, build the URL with the following structure:
base URL?variable1=value&variable2=value
Replace variable1 and variable2 with the variable names of the fields you want to populate on the form, and replace value with the value you want to appear in those fields. Append other variables to the URL by inserting an & symbol followed by the variable name, as shown above.
I believe Vladimir was hoping to add his own parameters in the URL that he can make use of for for currently unsupported field types
I'm interested to hear a specific use-case for this. You could try appending a hash to the URL and then parsing the URL with JavaScript.
For example:
baseURL#abcdefg
some code:
$(document).ready(function () { var testVal = window.location.href.match(/#.*/)[0].substring(1); $('#q1 input').val(testVal); })
The result:
Hi Vladimir,
I recommend you look at the source code for the page itself to find how to fill in data from the URL. They use Javascript (I believe) to handle this exact task.
I know that they can populate fields based on the URL parameters passed through but I have not looked recently to see if it's specifically Javascript or something else.
Thank you Eric and Kenneth.
You're right Kenneth i was looking for passing the parameter without assigning it to the field.
Customer would like to hide a section based on the /_initiator name but i think this is not there yet, so workaround would be to pass the parameter through URL to hide the section. This has disadvantages - parameter should be in URL and it will be somewhere in the form.... I included it in hidden section and made readonly but still not ideal.
Thank you again,
Vladimir
In the upcoming 9.1 version of Forms, you'll have access to some process variables within the Form Designer, including the process initiator, so you'll be able to set the default value or help text for a field to be the process initiator, current user, etc. Then, you could create a simple page rule based on the initiator or user currently viewing the form. Coupled with the new stored procedure functionality for lookup rules, the new variables in the Form Designer are pretty exciting!
Hi Eric,
I took quick look on the new version of the Forms (9.1) and did not find rule to show/hide section based on process initiator. Do i miss something?
Thank you,
Vladimir
Thank you Eric so much.
Vladimir
You're welcome!
Here is our situation.
We are able to bring the field over. However, we want it to be read-only. How can we accomplish this?
Hello again,
I have another question on this topic. The field is populating and works properly if user logs in and submits the form. If the form includes Approval process, the email sent to the approval destination (another user) with the link to the form to complete the process. New user accesses the form but {/_currentuser} inherits value from the initial process.... Is there any other parameter we can use to distinguish the current user name in this case?
Thank you
One way you can do this is by creating a separate form for the approval task. You'd add the fields from the starting form to this new form as variables, and add a new field with the {/_currentuser} variable as its default value.
Here's an example, where I've got an initial form that captures the first user, and then a second form used for the approval step.
After we create the first form, we take note of the variable for the field that's capturing the initial user. We then add that to the second form along with a new field that targets the new form's current user.
Thank you Eric,
We have a file uploaded on the initial form, how do we pass it to the next form?
Use the file upload field's variable on the second form. When the reviewer opens the second form, it will display the uploaded files.
Hi Eric,
I tried - it does not accept variable, saying specified variable already in use.
Can you post a screenshot of this error message and when it occurs?
Hi Eric,
That's interesting. The error happens in this scenario:
1. Form created without File Upload field;
2. Copy the form to create a second form;
3. Added File Upload field on to the first form;
4. Adding File Upload field in to the second form with the variable name from the first form created error below.
It does not if File Upload Field is already in place prior to copying form.
Putting this just for information only, after conversation with the customer it was decided to use a script based on your code earlier.
Also I think changing behavior of the CurrentUser variable to follow login user (even in the Approval process) would benefit Forms workflow. Can you consider it for the feature development?
Thank you again,
Sorry, just another request on the script portion, it works properly if I put URL#0 and monitor parameter after "#" but creating two additional questions:
1. If URL modified (#0 removed) it shows hidden section so public users can see it, is there any ways to prevent it?
2. Tried to modify URL path in the Form Publish tab - it does not allow to put any character other then alphanumeric there, can we do that differently?
Thank you,
The error you're describing happened because you made a copy of the form. The copy of the form already had the file upload field on it, so you couldn't add the variable for it again.
As for the URL error, could you please share a screenshot of this? There should definitely be a way to prevent users from seeing hidden sections. I'll take a look at the issue when you upload a screenshot and try to see what the issue is.
Hi Eric,
It is not an error per say, form's URL: http://localhost/Forms/8SSaP,
Public users use http://localhost/Forms/8SSaP#0, and it hides Admin part (screen shot 1)
however if they just delete last two characters in URL to return to the original one
(http://localhost/Forms/8SSaP) Admin section appears:
(screen shot 2)
Using this script
$(document).ready(function () {
if (window.location.href.match(/#.*/)[0].substring(1) == "0") {
$("#q3").hide();
}
})
If you're trying to hide those fields on the initial submission but have them visible for future approval tasks, you could go a different route:
$(document).ready( function() { if($('input[name="routingResumeId"]').val() =="") { $("#q3").addClass('hidden'); } });
Using this method, the person submitting the form wouldn't be able to see these fields and you wouldn't have to use the modified URL workaround you're using.
Thank you Sir!
You're welcome!