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

Question

Question

How to Fill Custom HTML Field from Database Lookup Values?

asked on March 13, 2015

We have a project we are currently working on for employee contracts. We will have a database with certain information about employees and what values should be in their contracts.

We would like to have an email address in Forms that will take the current user's email address, perform a database lookup based on the email address, and return back that records values for the contract. We then want to have a custom HTML field that basically does a mail merge with the returned information.

Is there any way this could be done? I thought about having putting the variables in the custom HTML field and then realized that the values for those variables technically are not set yet. Any help or ideas on this would be greatly appreciated.

1 0

Answer

SELECTED ANSWER
replied on March 16, 2015

Hi Blake,

 

I'm hoping someone out there has a better idea but here's one.

 

Use javascript and hidden fields to bridge the gap.

  1. Setup hidden fields to hold the data returned from your lookup rule
  2. Setup your lookup rules
  3. Setup your custom HTML section and use place holders where the variables would be such as {{variable1}} instead of laserfiche tokens.
  4. Use CSS to hide the custom div
  5. Use Javascript to wait a few seconds after the page loads waiting for look-up to complete, take the hidden values populated by the lookup and replace the placeholders in the custom HTML field, display the custom HTML field.

 

Javascript replace code:

http://stackoverflow.com/questions/5558613/javascript-replace-text-in-the-html-body

 

Ben used a form of this over here and it lead to a discussion of triggering off a look-up completing: 

https://answers.laserfiche.com/questions/68740/Dynamic-Variables-in-Custom-HTML-Field

 

 

I was tasked to create something similar. We had to put dynamic values into paragraphs within custom HTML fields. I stored the variables in the fields of a placeholder entry within the repository, served them back in a URL via workflow with values in the URL's query string to populate the hidden fields on the form. Then used javascript to replace the {{placeholders} in the custom HTML with the values of the hidden fields once the document finished loading. When they submit the form, the document is appended to the original placeholder entry so all dynamic information is stored with the entry. Unfortunately when Form s saves the instance to the repository the {{placeholder}} keys show instead of the appropriate values replaced with javascript.

 

Unfortunately, there doesn't seem to be a unique event to trigger off when a lookup completes. I've tried triggering off the ajax events but was unsuccessful as it appears there's multiple going on to generate the form.

 

Please post back if you find a better way!

1 0

Replies

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

Sign in to reply to this post.