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

Question

Question

Forms - Variable in custom HTML field doesn't appear on form image when saved to repository

asked on October 7, 2022

Hello,

I have a form with a custom HTML field. I have single line fields on the form that get filled via URL parameters, and some Javascript that allows the data in those fields to populate within the HTML field - screenshot below:

This works fine when filling out the form - the user sees "I, FirstName LastName, hereby consent..." in the HTML field. However, when the form is submitted to the repository, the FirstName and LastName is omitted and the HTML field looks like this:

Is there a way to get FirstName and LastName to appear in the HTML field on the image of the form when it gets submitted to the repository?

0 0

Answer

SELECTED ANSWER
replied on October 11, 2022

Are you looking at the monitor tab for that submission or an actual copy saved to the repository? The monitor will not show the values in that initial step because at that point in the process no values had been saved, but it would show them for steps that follow.

Also, for the Save to Repository task, don't use "save the form from this process step" and instead to use "save a form with current process data" to ensure you're getting data from a point where everything is saved.

1 0

Replies

replied on October 7, 2022

Only field values get posted on form submission. JavaScript changes to HTML are not included because they are client-side changes; this is standard for web forms and is important at least for security since client browsers can do whatever they want to the page content.

If you want the HTML changes to be "saved" you have a couple options:

 

Modify Your JavaScript

Update your JavaScript to run as soon as the form loads so it will re-add those fields when it is opened in the history view or saved to the repository.

However, note that aside from checkboxes and radio buttons, all field types are converted to div elements so the code for retrieving/populating those values has to be dynamic.

JavaScript still executes when the document is saved to the repository, you just have to make sure it is configured properly to account for the formatting differences.

 

Leverage Dataset Variables

You could add the data set variables for those fields to your HTML. If they are blank, like with the starting form, the value would just be blank (and your JS could fill them in).

However, as long as your hidden fields are saved with the submission, then they should be available for the HTML for subsequent tasks/processes to prefill.

Note that data set variables only reference saved values (i.e., they don't update in real-time like calculations), so you'll still need the JavaScript on the initial form.

2 0
replied on October 10, 2022

Hi Jason,

Thanks for the response. I apologize as I'm not even a novice when it comes to Javascript, so I have some further questions.

Here's my Javascript for these two fields:
 

/* Make First Name autofill in Custom Html*/
$(document).on("change", ".oath-FirstName-field", function() {
  $("#oath_FirstName").text($(".oath-FirstName-field input").val()).change();
});


/* Make Last Name autofill in Custom Html*/
$(document).on("change", ".oath-LastName-field", function() {
  $("#oath_LastName").text($(".oath-LastName-field input").val()).change();
});

We're actually not even hiding these single line fields for first name and last name - just filling them with URL parameters and then they display normally. What would we need to change so the Javascript runs as soon as the form loads?

I know I'm basically asking you to write my Javascript for me, so I absolutely understand if you don't have time for this :)

0 0
replied on October 10, 2022

Hi Jacob,

Try the dataset variable option I mentioned first. Your code will take care of things on the initial form and the variables will handle it everywhere else.

1 0
replied on October 10, 2022

This still leaves the HTML section blank - the first name and last name don't populate in the HTML section, but the single line fields are filled out properly based on the URL parameters. I must still be missing something.

0 0
replied on October 10, 2022

Do you still have your scripts running? As I mentioned in the first post, dataset variables only populate values that have already been submitted.

The dataset approach should address the issues with the values not showing in subsequent steps like saving to the repository, but it does not replace the scripts you already had for the starting form.

1 0
replied on October 10, 2022

I do, but it feels like there's something I should change now and I don't know what it is. 'oath-FirstName-field' and 'oath-LastName-field' are the CSS classes I've assigned to the two single line fields in question. Using the dataset variables in the HTML now, I feel like I need to update the Javascript but I don't know what exactly needs to change.

0 0
replied on October 10, 2022

If the javascript was working before, then the only thing that should change is adding the dataset variable inside the span elements of your custom HTML.

For example,

<span id="oauth_FirstName">{dataset/Your_Variable}</span>

In your starting form, the JavaScript you had already would replace the inner text of that span, so it doesn't matter that the variable is empty.

In your save to repository task, the dataset variable will be populated, and the JavaScript event won't fire. 

1 0
replied on October 10, 2022

Thanks so much for your assistance!

So this got me to the point where the HTML is displaying the name properly in the custom HTML section when the form is loaded like we want. However, upon submission, it's still omitted from the image of the form that gets submitted to the repository. What else would I be missing?

I appreciate the hand-holding through this issue!

0 0
replied on October 10, 2022

Are your placeholder fields (the ones populated by the url) hidden?

If so, are they set to Save or Ignore the value? If they're set to ignore, then you need to change that so the values can be retrieved later (this would be necessary for any approach to work).

If they are already set to Save, check one of your instance details, open the variable tab, and see if the values are actually saved after submission.

If the values are present, double check that your dataset variables match the actual variable names (selecting from the > menu is the safest option).

1 0
replied on October 11, 2022

Nope, the placeholder fields are not hidden. The dataset variables appear to match the real variable names. In the monitor tab, the image of the form does not show the names in the custom HTML section, but does show it in the single line fields as well as in the variable list for FirstName and LastName.

So, when filling out the form, the user does see the FirstName and LastName variables appear in the custom HTML. But, upon submission, I'm still losing it in the custom HTML while retaining it everywhere else. Since the user sees it properly when filling it out, and I can see the value of the variables in the Monitor tab, the variables seem like they must be correct and I'm missing something else?

0 0
SELECTED ANSWER
replied on October 11, 2022

Are you looking at the monitor tab for that submission or an actual copy saved to the repository? The monitor will not show the values in that initial step because at that point in the process no values had been saved, but it would show them for steps that follow.

Also, for the Save to Repository task, don't use "save the form from this process step" and instead to use "save a form with current process data" to ensure you're getting data from a point where everything is saved.

1 0
replied on October 11, 2022

Bang, that was it - choosing the "save a form with current process data." Thanks so much for the help!

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

Sign in to reply to this post.