display form based on selection

Kristopher Maier asked on January 17, 2017 22:42

Looking to display a form created using the On-line form web part. I have a field of "FormID" setup on the Page menu item that displays a list of the forms created. I have the On-line form web part within my layout.

I tried something like the below in the visibility macro area but I am not having success seeing the selected form. {% FormID == SiteObjects.Forms %}

Can you point me to how I can display the particular form selected in the drop down?

Thank you!

Recent Answers


Brenden Kehren answered on January 17, 2017 22:49 (last edited on December 10, 2019 02:30)

{%SiteObjects.Forms|(identity)GlobalAdministrator%}

1 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 17, 2017 22:56 (last edited on December 10, 2019 02:30)

You will need to use a macro to set the Form Name value of the On-line web form.

{% SiteObjects.Forms.Where("Id = "+convert.ToInt(MyFormIDField, -1)[0].FormName |(identity)GlobalAdministrator%}

Try that.

0 votesVote for this answer Mark as a Correct answer

Kristopher Maier answered on January 18, 2017 15:25 (last edited on December 10, 2019 02:30)

Brenden, I get a message of "Required form '4' does not exist." when putting that in the form name macro.

Trevor, I put that in and change MyFormIDField to FormID and nothing is displayed.

Even if I put this {% SiteObjects.Forms.webinarAchievingAPerfectSeal |(identity)GlobalAdministrator%} in the form macro I am not seeing anything either, I get a form not found, should I be seeing that form if I select it? Thanks!

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 18, 2017 21:47

Kristopher,

if you provide a form name, you need to adjust your Selection of the Form (in the page's Form tab) to return the FormName instead of the FormID.

That would probably be the best way to go about it, just adjust your page type so the select form gives the FormName, and pull that into the web part.

One small note, the Online-Form web part's field name i think is also "FormName" so you will want your Page Type's "Form Name" to be something else (like "PageFormName" so the macro uses it instead of the webparts value).

0 votesVote for this answer Mark as a Correct answer

Kristopher Maier answered on January 18, 2017 22:31 (last edited on December 10, 2019 02:30)

I seem to be getting closer, I changed the field to PageFormName like you mentioned above and the macro for the dropdown is SiteObjects.Forms.ItemsAsFields.FormName#

When using {%FormName = SiteObjects.Forms[3].FormName|(identity)GlobalAdministrator%} in the Form Settings of the Online Form Webpart I can see a form but it is not what I selected in the drop down. If I change the number in between the [] brackets it does load another form, I'm guessing that is the ID.

0 votesVote for this answer Mark as a Correct answer

Kristopher Maier answered on January 18, 2017 22:42 (last edited on December 10, 2019 02:30)

I just edited the macro to the following {%FormName = SiteObjects.Forms[PageFormName].FormName|(identity)GlobalAdministrator%}

It seems to be working! Thank you both

1 votesVote for this answer Mark as a Correct answer

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