f13c22f2-0396-41bc-fc21-2a25d4b82af2 = Name of the person
Goal: Retrieve the Form Name from FormId
and field name from field-guids.
Just to clarify; I have no recordId, so cant use RecordService, only raw information with guid of Formid and field-guids given- from which I would like to translate to their actual names.
I have checked the Developer document but couldnt find any way api/method.
One minor point is field.Alias doesnt exist, the name of the field is in field.Caption instead. You may wish to edit the post for others stumbling across for the same.
I found out about field.Caption from Nicholas Westby's posted link (another great find) as I didnt have access to VS or WM.
That explains it. I don't see the field.Alias property in Contour, but it is available in Forms. This is a minor difference between Contour and Forms but I think this is a good example of how a more clear division between Contour and Forms in both documentation and in the forum would be beneficial. Although many methods and techniques are similar (even the same) between Contour and Forms, there are many significant differences which makes learning how to use Forms very challenging. In some cases code from older Contour examples works 'as is' in Forms and sometimes not at all. Perhaps this has been suggested previously but I feel there should be a dedicated Forum category 'Umbraco 7 - Using Forms' to provide a dedicated place for Forms specific discussion. Does anyone know how to make such a request? Steve
This works in Forms, logging a single entry. Note the method: FormStorage.Saved (may be specific to Forms)
public class FormArchiveListener : ApplicationBase
{
public FormArchiveListener()
{
FormStorage.Saved += new EventHandler<FormEventArgs>(FormStorage_FormUpdated);
}
void FormStorage_FormUpdated(object sender, FormEventArgs e)
{
FormStorage storage = (FormStorage)sender;
LogHelper.Info(typeof(FormArchiveListener), "A form is Saved!");
}
}
Do you think we should start a new topic with this? Cheers Steve
is there any way to get field data? i could fetch the Alias of fields , but i need to get the values of the fields. can you please help,Thanks in advance.
Keilo,
For your specific example, there is also a FormStorage.GetForm(guid) method which returns a Form object. Interestingly, I see that Intellisense is not active when calling Umbraco.Forms.Data.Storage.FormStorage - this could be unique to my install of VS but makes using the class difficult (hard to know it's even there!) Steve
Not sure why but the Intellisense doesn't seem to kick in with the class Umbraco.Forms.Data.Storage.FormStorage until after instantiating the variable.
Retrieve name of all forms and their field names from Guids, via API
Is there any api call/routine to retrieve the list of all Contour Forms' "Name" with corresponding "FormId" in a razor script?
Or given the "FormId" and fieldGuid (input field's guid), how can I retrieve the name of the form and input fields?
Example: (given)
FormId = fa25a3c0-c025-4dc2-a7a5-e961e23418e0
512c22f2-0396-45bc-bc25-2a25d4b84a71 = [email protected]
f13c22f2-0396-41bc-fc21-2a25d4b82af2 = Name of the person
Goal: Retrieve the Form Name from FormId and field name from field-guids.
Just to clarify; I have no recordId, so cant use RecordService, only raw information with guid of Formid and field-guids given- from which I would like to translate to their actual names.
I have checked the Developer document but couldnt find any way api/method.
Hi Keilo,
Here is a basic loop which should help you:
The above was hacked together based a more complete (complex) listing that I found recently here on GitHub
Hope that is helpful!
Steve
Hi Steve
Thanks a million! Exactly what i was looking for.
One minor point is field.Alias doesnt exist, the name of the field is in field.Caption instead. You may wish to edit the post for others stumbling across for the same.
I found out about field.Caption from Nicholas Westby's posted link (another great find) as I didnt have access to VS or WM.
cheers!
You're welcome - great to hear it was helpful.
Interesting that you don't see field.Alias - are you using Contour?
Hey Steve
Yes on Contour latest (not Forms) on umbraco 7.1.8
That explains it. I don't see the field.Alias property in Contour, but it is available in Forms.
This is a minor difference between Contour and Forms but I think this is a good example of how a more clear division between Contour and Forms in both documentation and in the forum would be beneficial. Although many methods and techniques are similar (even the same) between Contour and Forms, there are many significant differences which makes learning how to use Forms very challenging. In some cases code from older Contour examples works 'as is' in Forms and sometimes not at all.
Perhaps this has been suggested previously but I feel there should be a dedicated Forum category 'Umbraco 7 - Using Forms' to provide a dedicated place for Forms specific discussion.
Does anyone know how to make such a request?
Steve
Cant agree more, that would definitely help to bring learned Contour knowledge through the years and assist in transition.
On related topic, is there any Save event handler for Contour like we have for Content;
..FormSaved += new EventHandler ...
that I can execute code whenever a form is created/saved?
Haven't tried this but it appears to be what you are looking for:
Just did a quick test by putting a .cs to App_Code
When I go to any form and click Save, the I get 2 log entries "A form is Saved" for 1 save action; i.e. the routine is called 2 times.
Not sure if i am missing something, or its not the right event
This works in Forms, logging a single entry. Note the method: FormStorage.Saved (may be specific to Forms)
Do you think we should start a new topic with this?
Cheers
Steve
Hello Steve,
is there any way to get field data? i could fetch the Alias of fields , but i need to get the values of the fields. can you please help,Thanks in advance.
You can find some examples of iterating over forms/fields here: https://github.com/rhythmagency/rhythm.umbraco.extensions/blob/master/trunk/Rhythm.Extensions/Rhythm.Extensions/Utilities/ContourUtility.cs
The function GetFieldValues has code very similar to that posted by Steve above.
Thanks Nicholas!
This is a great find. Helped me to get it up and running.
cheers!
Keilo,
For your specific example, there is also a FormStorage.GetForm(guid) method which returns a Form object.
Interestingly, I see that Intellisense is not active when calling Umbraco.Forms.Data.Storage.FormStorage - this could be unique to my install of VS but makes using the class difficult (hard to know it's even there!)
Steve
Not having access to intellisense will be an issue, as I see myself digging the FormStorage.GetForm(guid) when importing entries.
What happened is that I have been given formguids (where each contain fieldguids with values).
I can decode and present the Name, fieldname to the end-user with the first posted routine.
After which I will need to "import" those entries into an Umbraco Instance where the exact forms (guids) exist in the instance.
Not sure how to go about that yet.., but Im sure it will start with FormStorage.GetForm(guid) to get handle to the form to start an import job(?).
given: formguid and their fieldguids and values
goal: import values for each form, to target instance Contour (i.e. creating new entries programmatically)
Not sure why but the Intellisense doesn't seem to kick in with the class Umbraco.Forms.Data.Storage.FormStorage until after instantiating the variable.
is working on a reply...