Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Corry 34 posts 171 karma points
    Sep 26, 2014 @ 17:57
    William Corry
    0

    Trying to display content on a summary page

    I have the foloowing bit of code that worked perfectly on an old umbraco install (4.9) (and the latest version of contour you can have with 4.9):

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Umbraco.Forms.Mvc.DynamicObjects;
    @using Umbraco.Forms.Data.Storage
    @using Umbraco.Forms.Core
    @{
    var recordId = Request.QueryString["recordid"];
    if (!string.IsNullOrEmpty(recordId)) { using (var recordStorage = new RecordStorage()) { var rec = recordStorage.GetRecord(new Guid(recordId)); dynamic record = new DynamicRecord(rec); @record.firstname foreach( var field in record.RecordFields ) { var sThisField = field.Value.Field.Caption; var sThisValue = field.Value.ValuesAsString(); @sThisField - @sThisValue} } } }

    However this is failing on Umbraco 7.1.6 and contour 3.21 its seems to be the @record.firstname that breaks it as when that is removed it works. However I need to target particluar fields am I missing something really obvious?

  • William Corry 34 posts 171 karma points
    Sep 27, 2014 @ 12:33
    William Corry
    0
    Error loading MacroEngine script (file: file.cshtml, Type: ''. Exception: System.InvalidOperationException: Sequence contains no elements
       at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
       at Umbraco.Forms.Mvc.DynamicObjects.DynamicRecord.TryGetMember(GetMemberBinder binder, Object& result) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.Mvc\DynamicObjects\DynamicRecord.cs:line 64
       at CallSite.Target(Closure , CallSite , Object , String )
       at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
       at ASP._Page_macroScripts_file_cshtml.Execute() in c:\Users\William\Documents\My Web Sites\fasterthanlight\MacroScripts\file.cshtml:line 14
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
       at System.Web.WebPages.WebPage.ExecutePageHierarchy()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
       at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
       at umbraco.macro.loadMacroScript(MacroModel macro)
       at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
    

    Here is the error from the logs the field I am trying to display is First name which in the old umbrac all I did was use @record.firstname but have no idea what I am doing wrong here.

  • William Corry 34 posts 171 karma points
    Sep 29, 2014 @ 10:27
    William Corry
    0

    Ok after much head banging and swearing at the screen (I fill better now lol)

    It appears Umbraco 7.1.6 and contour are not communicating the same as if I change the property name to just 1 word ie name and use @record.Name then the data shows. This looks like a bug to me as the property should be combineing First name to Firstname am I right?

    Could this be looked at ASAP as obvioulsy this is a limitation.

  • Paul Sterling 718 posts 1534 karma points MVP 9x admin c-trib
    Sep 29, 2014 @ 20:18
    Paul Sterling
    0

    Hi William -

    Can you try a slightly different approach as outlined in this post:  http://www.proworks.com/blog/2013/07/18/how-to-display-the-submitted-record-from-umbraco-contour-on-the-thank-you-page/

    Really its just using a different method to fetch the records intially:

    @{ var approvedRecords = Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromFormOnPage(Model.Content.Parent.Id, "YOURFORMGUID");
    var submittedRecord = Request.QueryString["recordid"]; 
    if( !String.IsNullOrEmpty(submittedRecord) ) 
    { <ul>@foreach(varrecordinapprovedRecords){if(submittedRecord==record.Id){<li><em>@record.Created.ToString("dd MMMM yyy")</em>@foreach(varfieldinrecord.RecordFields){// First, build table rows for non-editable fields varsThisField=field.Value.Field.Caption;varsThisValue=field.Value.ValuesAsString();<p>@sThisField - @sThisValue</p>}</li>}}</ul> } } 
  • William Corry 34 posts 171 karma points
    Sep 30, 2014 @ 10:01
    William Corry
    0

    Thats where I got the idea from in the first place (although I used the first comments suggestion).

    Thats does not explain when @record.Name works np when the label is Name but @record.Firstname does not work when the record is labelled First name.

    The results work no problem for the complete list its just when I target individual record field values.

    The over solution had the smae issue worked when one word not when 2.

Please Sign in or register to post replies

Write your reply to:

Draft