PeteCam
Rookie

How can I insert dynamic text into a rich text box and have it save when form is submitted?

I have a rich text box with the following text:
"I have been a [Role] during all or some part of [Year]. I hereby affirm that I have reviewed the Code of Business Conduct and all applicable blah blah blah...."

when the form opens, some javascript code replaces the [Role] and [Year] values with the individual's role and the previous year. However, after submitting the form, the [Role] value is displaying as [Role] again. How can I replace this value and have it stay when user submits?

 

0 Kudos
Reply
4 Replies
mlauer
Collaborator

Re: How can I insert dynamic text into a rich text box and have it save when form is submitted?

0 Kudos
Reply
PeteCam
Rookie

Re: How can I insert dynamic text into a rich text box and have it save when form is submitted?

I just gave this a try, but no luck, it's still not saving the change.  Here's what I tried:

var stri = (NWF$('.richText1').html());
NWF$('.richText1').html(stri.replace("[Role]", usrRole));
NWF.FormFiller.Functions.ProcessOnChange($NWF('.richText1'));
 
this didn't work, so next I tried this:
var stri = (NWF$('.richText1').html());
NWF.FormFiller.Functions.ProcessOnChange(NWF$('.richText1').html(stri.replace("[Role]", usrRole)));
 
when that didn't work, I tried this:
var stri = (NWF$('.richText1').html());
NWF$('.richText1').html(stri.replace("[Role]", usrRole));
NWF$('.richText1').trigger("focus out");
 
None of these are working.  When the form gets submitted, the saved form's rich text box shows [Role] again.
 
 
 
0 Kudos
Reply
kunalpatel
Collaborator

Re: How can I insert dynamic text into a rich text box and have it save when form is submitted?

@PeteCam instead of building text in rich text box, why can't you use the calculated control and then used that named control to populate your text box column?

0 Kudos
Reply
PeteCam
Rookie

Re: How can I insert dynamic text into a rich text box and have it save when form is submitted?

It was a solution built 4 years ago, and we just discovered that the text in the rich text control wasn't being saved.  I've since discovered that Nintex doesn't save the full form on submit.  It only saves the fields linked to SharePoint fields, and anything else in the form is based on the published template.  Update the template, and all historical records get the updated template too.  

Ultimately, I solved the issue by having the JavaScript edit the rich text box in view mode by pulling from the Role field saved to the list and inserting into the html during load.  So even though the rich text box isn't being saved as originally envisioned, whenever it's viewed it at least displays the correct info.

0 Kudos
Reply