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?
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.
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.
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):
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?
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.
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.
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:
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.
is working on a reply...