Update Online Form field value in transformation

Amanda Ford asked on August 31, 2018 19:52

I added an online form (Bizform) control to a transformation. I'd like to update the value of a field in the form called "WhitepaperTitle" with the value of one of the page type's fields called "Title." I tried setting the value suing SetDataValue and the following code. It's not working. Any suggestions?

<cms:BizForm runat="server" ID="BizForm" FormName="Whitepapers_8" EnableViewState="false" RedirectUrlAfterSave='<%# GetFileUrl("Whitepaper") %>' SetDataValue='"WhitepaperTitle","<%# Eval("Title") %>"' />

Recent Answers


Dragoljub Ilic answered on September 1, 2018 22:58 (last edited on December 10, 2019 02:31)

Hi Amanda,

You can set default value of the field directly on the form field as 'Default value'. You can do that by going to specific form (Whitepapers_8) and select fields tab. Then select field 'WhitepaperTitle' and as default value put macro method (click on small arrow on the left):{% CurrentDocument.DocumentName |(identity)GlobalAdministrator%}

Best regards, Dragoljub

0 votesVote for this answer Mark as a Correct answer

Amanda Ford answered on September 3, 2018 09:25

Thanks Dragoljub, but it's not the current page's page title I need, but a field called "Title" in the particular transformation.

I have a repeater that displays several white papers. When I click on one, my transformation brings up a modal window with the online form, the user fills it out and then the user is redirected to the white paper. I want to populate a hidden field in the online form with the name of the white paper so I know which white paper they downloaded.

0 votesVote for this answer Mark as a Correct answer

Dragoljub Ilic answered on September 3, 2018 11:19

Hi Amanda,

Sorry, I didn't understand well your question. If you want to set Title in transformation, from repeater, then you can try to bind it on event 'OnOnBeforeDataLoad', so you need to add something like this on your BizForm control instead of SetDataValue: OnOnBeforeDataLoad="BizForm_OnBeforeDataLoad"

Then with server side script, you should get title and set it into desired field:

  protected void BizForm_OnBeforeDataLoad(object sender, EventArgs e)
  {
    ((CMS.OnlineForms.Web.UI.BizForm)sender).Data["FormFieldName"] = Eval("TitleFromTransformation");
  }

This need to be added directly in ASCX transformation, wrapped by 'script' tag (runat="server").

Best regards, Dragoljub

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.