Skip to main content
Nintex Community Menu Bar
Question

how to replace and re-evaluate template text

  • July 11, 2024
  • 3 replies
  • 7 views

Forum|alt.badge.img+1

Hi all,
I’m looking for a way to inject template text with merge fields dynamically to my page (at runtime, with JS).

Example:
I want to add a text like “… the latest status is  {{status__c}} …”  and have the merge field transformed to status value.

My idea was to use a template field, set it’s new text and render it again.
I replaced the fields text in the HTML DOM element with JS (which works). But after calling the render() method of the template field,  the old/previous content is set again.

Any suggestions?

This topic has been closed for replies.

3 replies

Forum|alt.badge.img+17
  • Nintex Employee
  • July 11, 2024

If you are trying to update the value to be somthing different than what is in the model - you will have to try something different.  The easiest way to go about this will be to change the value of the field in your model (status__c) and then re-render the template. 


Forum|alt.badge.img+9

If you are using the standard renderer in your javascript, you may have this:

  • skuid.ui.fieldRenderers[field.metadata.displaytype].read( field, value )
The javascript needs to change value before reaching the renderer statement.


Forum|alt.badge.img+1
  • Author
  • July 11, 2024

Rob/Mike, thanks for your hints.
I found the merge API is what I was looking for (https://docs.skuid.com/latest/en/skuid/merge-syntax/)

var mergedHtml = skuid.utils.merge( <br> 'row', <br> myHtmlTemplate, <br> {createFields:false}, <br> model, <br> row ).html();<br><br>

I think, my problem description was not clear enough.