I want to set the text of a CustomHTML using a Field Lookup rule. Is this possible? If so, how?
Question
Question
Replies
I don't think it is possible out-of-the-box, but you could do it with some JavaScript.
- Create a span or some other element with a set ID attribute
- Create hidden field to store the lookup value
- Attach a change event handler to the hidden field
- On change, update the contents of the element with the value of the field
Depending on when the data is retrieved, it is also worth noting that variables with saved values can be used in the Custom HTML. Default variables like current user are available at the start, but your custom variables wouldn't be available until they were populated in a previous submission/task.
I tried this before I posted my Question and the .change event on the hidden field triggers before the text of the hidden field actually gets updated.
It should still trigger again once the text is populated. I do this exact thing all the time, so something else must be happening.
The easiest way to test would be to just log the field text to the console every time the event fires; that way you can see the exact sequence.
Also note that depending on how you plan on using the data, you could have it populate a multiline text field and make the field read-only. It will show a little differently than a Custom HTML field, but usually serves it purpose.