I'd like to loop through each record for a Contour form in Razor. I tried this http://www.nibble.be/?p=102 approach with Tim Geyssens dynamicobjects. However that does not seem to work for me, probably because I have field names with spaces and non-english chars (not very unusual as field names = captions).
@{ var f = Contour.Addons.DynamicObjects.Library.GetRecordsFromForm("form-guid"); }
@foreach (dynamic rec in f) { <p>@rec.Created.ToShortDateString()</p> // works <p>@rec.Whatever</p> // error "Sequence contains no elements" }
The C# samples I found out there was a bit complicated and xml'y(?)
I am looking for GetRecord(string id) method, but not finding the same.
The purpose is to fetch the information some time later from the url send in email using record id.
Any tips.?
The strange thing with the form is that allows same captions multiple times. So, if there are multiple Field groups with same field names, it is shown as same entry in the Forms(columns sorted) adjacent to each other. @rec.GetField("email").Values will return multiple emails, but user won't know which one we are getting. There should have been some thing like @rec.Fields[0].Value as we see in the Form UI. I have just started with Contour and trying to do migration of a complex form.
When I add a field name with more than 2 words, i.e. @record.GetField("First track name").Values[0]; I then get the following error --> Error loading MacroEngine script (file: list.cshtml)
Loop through each record with razor
Hi,
I'd like to loop through each record for a Contour form in Razor. I tried this http://www.nibble.be/?p=102 approach with Tim Geyssens dynamicobjects. However that does not seem to work for me, probably because I have field names with spaces and non-english chars (not very unusual as field names = captions).
The C# samples I found out there was a bit complicated and xml'y(?)
TIA
Jonas
Ah, found a sln
hi Jonas,
Do you know any documentation of this.
I am looking for GetRecord(string id) method, but not finding the same.
The purpose is to fetch the information some time later from the url send in email using record id.
Any tips.?
The strange thing with the form is that allows same captions multiple times. So, if there are multiple Field groups with same field names, it is shown as same entry in the Forms(columns sorted) adjacent to each other. @rec.GetField("email").Values will return multiple emails, but user won't know which one we are getting. There should have been some thing like @rec.Fields[0].Value as we see in the Form UI. I have just started with Contour and trying to do migration of a complex form.
Thanks,
Rajeev
Hi,
I'm also trying to loop through each record and it doesn't work, I have spent over hours trying different things. My code is:
@using Contour.Addons.DynamicObjects
<ul>
@foreach (dynamic record in Contour.Addons.DynamicObjects.Library.GetRecordsFromForm("form-guid"))
{
<li>
@record.Created.ToString("dd MMMM yyy");
@record.GetField("Music type").Values[0];
@record.GetField("First track name").Values[0];
</li>
}
</ul>
----
When I add a field name with more than 2 words, i.e. @record.GetField("First track name").Values[0]; I then get the following error --> Error loading MacroEngine script (file: list.cshtml)
Any advise greatly appreciated.
I use this syntax:
is working on a reply...