How to Write a Transformation for an Alternative Form

Mike Bilz asked on June 28, 2017 21:15

Hello Kentico Team,

I have an Alternative Form connected to a User Contribution Web Part. This alternative form has additional fields which do not appear in the standard form.

How do I access these additional fields within a transformation?

When I write an Eval like <%# Eval("MyCustomField", true) %> it returns nothing.

Is there a special declaration or piece of code I need to add? or is this Alternative Form data not actually stored anywhere?

Thanks.

-mike

Correct Answer

Brenden Kehren answered on June 28, 2017 22:16

Understood now Mike. I thought you were using an actual Form within your page type.

For this, if your alternative form has a field in which the actual page type does not, that data is not being stored in the database. So what you need to do is create that field in the main page type definition and then show it on your alternative form(s) as needed.

See the screenshot below. I created an alternative form for the Articles page type and added a new field and it has this at the top of the new field "This field will be created without database representation". So go back and add it to the page type definition and not the alternative form.

Image Text

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on June 28, 2017 21:25

Sounds like you might be confusing 2 different things:

  1. Alternative forms - used for data management i.e.: insert/edit of structured data
  2. Transformations - used for displaying data from structured content

If you have a form being displayed in a transformation you still don't need to alter a transformation, you'd need to deal with your alternative form or form definition of that object (page type, class, form, etc.).

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on June 28, 2017 21:46

Hi Brenden, I may not have been entirely clear in my issue.

I have created an Alternative Form for the Event page type, which has additional fields not present in the main form.

I am creating a transformation to display Event pages, and would like to include the content of these additional fields in that transformation for events created with the Alternative Form.

How do I access the data from these fields?

Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 28, 2017 21:59

First you'd have to have that event tied to a form somehow. Then in the transformation you'd need to perform a lookup of that form data based on that field value in the event page type. The downside of this is when you perform that API query, it will get all the form submissions and not a single one. So for that given event, you will display all the submissions for that event.

If you have that one form hooked up to multiple events, you will get all the form submissions for all the events. So not really an ideal situation; you'd want to have a new form for every event. You also need to think about performance. If you're only doing this for a single event it's probably not too bad but if you're loading a list of events and every event has to go out and get form submissions, it could cause a lot of problems.

Here are the API examples for getting online forms and their data.

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on June 28, 2017 22:09

Hi Brenden, I think we are still talking past each other.

I have a Contribution List web part, which people can use to create Event page types, using a special Alternative Form (Code Name: PublicSubmission).

The issue I am having is that the Alternative Form has additional fields which are not present in the standard form used to create a new Event.

How do I access these additional fields in my Event page transformation?

Sorry for any confusion. Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on June 28, 2017 22:10

You created fields in the alternative form that aren't actual fields on the page type? I am not 100% sure those field values are actually saved anywhere. I could be wrong though.

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on June 29, 2017 01:44

Thanks everyone. I've got it all sorted now, and everything is working well.

Glad to know it was just a silly mistake on my part.

0 votesVote for this answer Mark as a Correct answer

Amanda Snow answered on December 11, 2017 13:56

Hiring a professional academic writing service is the way out in case a well-written is required cheap essay writing service Moreover, here is the website, which is able to help on the way of getting a paper done in the best way possible. Enjoy using the service and you will not be disappointed.

0 votesVote for this answer Mark as a Correct answer

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