Anybody have an idea as to why the dot notation does not seem to work as described above?
I found an alternative that does work though:
@foreach (dynamic record in Umbraco.Forms.Mvc.DynamicObjects.Library.GetRecordsFromForm("c3682d05-716a-48bf-9348-790339692999"))
{
<tr>
@foreach (var field in record.RecordFields)
{
if(@field.Value.Field.Caption.Contains("First Name"))
{
<td>@field.Value.ValuesAsString()</td>
}
But still, I would expect the approach described here t also work...
In hindsight, I think the issues I described here are related to my using quite a few non-alphanumeric characters and Trygetmember() not cleaning things up enough.
If you want to get multiple fields of a record (e.g. when populating several 's in a table with record data, the exception being thrown is quite cryptic, mapmaking me think things were not working at all whereas now, I noticed record.Email would work while record.CVPDF would not work for a caption which was originally "CV (PDF)" ith the brackets being the culprit here.
As far s I can tell (I last checked the .21 version of contour) this is still not entirely resolved as there is a small error in the reject that is used to clean up the caption in the dynamic implementation.
I have resorted to using non-dynamic calls to get to the data I need.
You can do stuff like:
...
RecordStorage rsStorage = new RecordStorage();
// In some cases (many records) I found it to be fastest to work with the guide with which certain fields are stored in records.
// Not the most practical but it you do not need to do it often...
const string fileF = "430e0b11-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
Guid fileG = new Guid(fileF);
...
@{
int i = 0;
IEnumerable<Record> lRecs = rsStorage.GetAllRecords(new Guid("cca978e7--xxxx-xxxx-xxxx-xxxxxxxxxxxx")).Where(r => r.UmbracoPageId == Model.Id);
}
@if (lRecs.Any())
{
foreach (var record in rsStorage.GetAllRecords(new Guid("cca978e7-xxxx-xxxx-xxxx-xxxxxxxxxxxx")).Where(r => r.UmbracoPageId == Model.Id).OrderBy(r => r.Created))
{
record.UmbracoPageId.ToString();
<tr @New(record.Created)>
<td><a href="@("http://www.myurl.com" + @record.GetRecordField(fileG).ValuesAsString())">Download</a></td>
<td>@CleanString(@strCreated)</td>
</tr>
i++;
}
}
That snippet actually generates a table containing uploaded files.
There are some more threads about this around here.
I'll try and have a look at the latest nightly also...
how are you guys handling the sequence contains no elements exceptions all over the place. using dynamics or DynamicRecord are you wrapping each field in a try catch?
I have tried the above code, but for me it is generating an error message (see below). Any ideas?
There is already an open DataReader associated with this Command which must be closed first.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
I’ll see if I have some time today to take a look at it in a new environment. it states that you have another datareader open which might be version related. so I will try in an identical setup.
Meanwhile you could try to come around it by making a new simple form with just one field. a new view with macro and just put a simple version of your script in it for testing purposes and slowly build it up.
So only inheriting and importing what you must and nothing else.
Take the following script and see if it works, if it does you know it’s something else:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Umbraco.Forms.Mvc.DynamicObjects
@{
foreach (dynamic record in Library.GetRecordsFromForm("03928f28-cceb-4eb4-8eb2-4c1f69927430"))
{
}
}
Get record info using Razor
I have a Contour form set up which, among other things, allows someone to submit an Email address.
The caption for the form field is "Email".
Based on all submitted forms I'd like to present a page on the website displaying all submitted records but this yields an error message...
Strangely, following returns "true":
Then again:
Also returns true, even if "SomethingRandom" is not a field on the form (and should therefore not be a property of the record).
This is rather urgent, does anybody have an idea??
Cheers,
Kris
Anybody have an idea as to why the dot notation does not seem to work as described above?
I found an alternative that does work though:
But still, I would expect the approach described here t also work...
Comment author was deleted
No can you show me the caption of the field that doesn't work, then I can test :)
Hi Tim,
In hindsight, I think the issues I described here are related to my using quite a few non-alphanumeric characters and Trygetmember() not cleaning things up enough.
If you want to get multiple fields of a record (e.g. when populating several 's in a table with record data, the exception being thrown is quite cryptic, mapmaking me think things were not working at all whereas now, I noticed record.Email would work while record.CVPDF would not work for a caption which was originally "CV (PDF)" ith the brackets being the culprit here.
Captions such as:
Position (1st) CV (PDF) ...
Just wondering how you ending up dealing with the brackets as I'm using a description of File Upload (max size 2mb)
Thanks
Hi,
As far s I can tell (I last checked the .21 version of contour) this is still not entirely resolved as there is a small error in the reject that is used to clean up the caption in the dynamic implementation.
I have resorted to using non-dynamic calls to get to the data I need.
You can do stuff like:
...
That snippet actually generates a table containing uploaded files.
There are some more threads about this around here.
I'll try and have a look at the latest nightly also...
how are you guys handling the sequence contains no elements exceptions all over the place. using dynamics or DynamicRecord are you wrapping each field in a try catch?
seems pretty messy
Well the easiest way I have found is to do like this:
Regards, Scott
Hello
I have tried the above code, but for me it is generating an error message (see below). Any ideas?
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
thanks
Hi Aaeda
Please share a bit of code.
Kind regards, Scott
Could you post the whole script?
Hello Scott
Here it is
getting the error message on the 'foreach' line
Oh and also, which version do you use of umbraco and forms
Oh yes, it is umbraco 7.7.8 and forms 6.0.7
I'm sorry but could you post the whole script so we can see context please
Ok, here it is
@using createsend_dotnet; @using Umbraco.Forms.Mvc.DynamicObjects
@{
}
Could you try for a moment and remove the @using createsend_dotnet; part..
I have tested it without and found it working.
hello
thanks for your help. but I am still getting the error even after removing the create_dotsend. Any idea why?
thanks
I’ll see if I have some time today to take a look at it in a new environment. it states that you have another datareader open which might be version related. so I will try in an identical setup. Meanwhile you could try to come around it by making a new simple form with just one field. a new view with macro and just put a simple version of your script in it for testing purposes and slowly build it up. So only inheriting and importing what you must and nothing else.
Take the following script and see if it works, if it does you know it’s something else:
Scott
Ok thanks a lot. I will try that.
is working on a reply...