ProWorks Blog

How to Display the Submitted Record from Umbraco Contour on the Thank You Page

By  |  Thursday, July 18, 2013  |  , , ,  |  3 comments

Ever wanted to display the users submission from Umbraco Contour on a Thank You page, but didn't know how to access the API?  Well, this post is for you.

This could be adapted as a confirmation page to a PayPal payment form post or simply to let them know that the submission was successful.

Here are the steps:

1. Create a "Thank You" page under the page that contains your Umbraco form.

Contour-ThankYou

2. In the Settings area set the Thank You page as the new page you just created.

Contour-ThankYouSettings

3. Create a new Razor macro with the following code and allow it to be inserted into the Rich Text Editor

@inherits umbraco.MacroEngines.DynamicNodeContext
@using Umbraco.Forms.Mvc.DynamicObjects
	

    @{
        var approvedRecords = Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromFormOnPage(Model.Content.Parent.Id, "YOURFORMGUID");
        var submittedRecord = Request.QueryString["recordid"];
		
		if( !String.IsNullOrEmpty(submittedRecord) )
		{
			<ul>
			@foreach( var record in approvedRecords )
			{
				if( submittedRecord == record.Id )
				{
					<li>
						<em>@record.Created.ToString("dd MMMM yyy")</em>
					
						@foreach( var field in record.RecordFields )
						{
							// First, build table rows for non-editable fields
							var sThisField = field.Value.Field.Caption;
							var sThisValue = field.Value.ValuesAsString();
		
							<p>@sThisField - @sThisValue</p>
						}
		
					</li>
				}
			}
			</ul>
		}
    }

4. Drop the Macro into the Body Text or RTE of your Thank You page that you just created.

Contour-ThankYouMacro

That should look something like this:

Contour-ThankYouResults

Now you can modify that to be an invoice, form to post for payment, or whatever you need.

3 comments for “How to Display the Submitted Record from Umbraco Contour on the Thank You Page”

  1. Posted 7/19/2013 at 2:41:47 AM

    Jason,

    There is a better of doing this

    using (var recordStorage = new RecordStorage())
    {

    var rec = recordStorage.GetRecord(new Guid(recordId)); //actual form record with data

    dynamic record = new DynamicRecord(rec); //get dynamic object for ease of use on display

    }
    @record.FirstName

    regards

    Ismail

  2. Posted 7/22/2013 at 10:28:54 PM

    Thank you Ismail Mayat. Used it.Very useful to me.

  3. Posted 7/24/2013 at 10:46:21 AM
    Gravatar of Jason

    Awesome Ismail, thanks!

Post a comment