Can we get an event raised before a record is retrieved? It seems Umbraco Forms v4.0.3 does not support getting data from an external data source, only sending data there and then using it's local RecordStorage. If I had an event before it retrieves the record I could refresh the RecordStorage from the external data source.
Just looking in the code but unsure where to place the event, so you want to have it before the records get retrieved (so the place where they get retrieved is the records viewer)
I need to be able to refresh the data storage from an external data source when this event is fired so that my data is up to date. Does that make sense?
So instead of fetching the records from the forms storage you want to bypass that and return data from a custom source (and this is for use in the entries viewer)
OK I can see the TreeNodesRendering event fired when you are in the back office. How do I create my own records viewer and hook this in? Will I be able to extend the existing one? Can you please provide more detailed code example.
Then you'll need to inject a angularjs controller, and you'll also need an api controller that will feed the data to the controller, will also get you some sample code of that
OK thanks for that. But this is just implementing a new back office entries viewer. I need the actual form that the user of my website sees to display the correct data that comes from an external source. Umbraco Forms does not currently support this and changes to the external data are not picked up and there is no way for me to retrieve them.
i.e. when they navigate to:
www.mywebsite.com/myform?recordid=1
I have two options:
Hook into a synchronous event before any records are received and use the RecordService to update the records from the external source.
Hook into the an event the retrieves the Records and return the correct data then.
If you can help me implement either of these it would be greatly appreciated!
[PluginController("Custom")]
public class EntriesApiController : UmbracoAuthorizedJsonController
{
Entry[] entries = new Entry[]
{
new Entry { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 },
new Entry { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M },
new Entry { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M }
};
public IEnumerable<Entry> GetAllEntries(string formId)
{
return entries;
}
public Entry GetEntryById(int id)
{
var entry = entries.FirstOrDefault((p) => p.Id == id);
if (entry == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return entry;
}
}
Entry model
public class Entry
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
}
Event before record is retrieved?
Hi !
In a similar vain to this post: https://our.umbraco.org/forum/umbraco-pro/contour/48123-Event-when-entry-is-deleted
Can we get an event raised before a record is retrieved? It seems Umbraco Forms v4.0.3 does not support getting data from an external data source, only sending data there and then using it's local RecordStorage. If I had an event before it retrieves the record I could refresh the RecordStorage from the external data source.
These events seemed to exist in Umbraco 6.
Cheers!
Tom
Comment author was deleted
Sure thing, would you mind creating it as a feature request at http://issues.umbraco.org/issues/CON
FYI - I added issue: http://issues.umbraco.org/issue/CON-790
Great, thanks!
Comment author was deleted
Thanks, I'll assign this to version 4.2 (the next upcoming version)
Do you know when this is due for release?
Comment author was deleted
Will add the event in this week then you can update to a nightly build. Will report back here when that is done
Comment author was deleted
Just looking in the code but unsure where to place the event, so you want to have it before the records get retrieved (so the place where they get retrieved is the records viewer)
Yes, I think before as a synchronous event.
I need to be able to refresh the data storage from an external data source when this event is fired so that my data is up to date. Does that make sense?
Comment author was deleted
So instead of fetching the records from the forms storage you want to bypass that and return data from a custom source (and this is for use in the entries viewer)
Comment author was deleted
Wouldn't it be easier to just create your own entries viewer? And hook into the menu rendering to show your own viewer instead of the default one
OK that could work but I'm not sure exactly what you mean. Could you show me some example code?
Comment author was deleted
Hook into menu rendering example is on the bottom of this page https://our.umbraco.org/documentation/Extending-Umbraco/Section-Trees/trees-v7
OK I've added the following code but the event is not firing when I load the form:
Forgive me - I'm new to Umbraco! :)
OK I can see the TreeNodesRendering event fired when you are in the back office. How do I create my own records viewer and hook this in? Will I be able to extend the existing one? Can you please provide more detailed code example.
Comment author was deleted
You can basically create your own angularjs view and controller, and point to that from your menu option
Will get some code snippets together
Comment author was deleted
Ok this is the code snippet that will update the entries node to go to a custom view
so then it's a matter of creating the file /App_Plugins/UmbracoForms/backoffice/form/customentries.html and implementing your own records viewer
Comment author was deleted
Then you'll need to inject a angularjs controller, and you'll also need an api controller that will feed the data to the controller, will also get you some sample code of that
OK thanks for that. But this is just implementing a new back office entries viewer. I need the actual form that the user of my website sees to display the correct data that comes from an external source. Umbraco Forms does not currently support this and changes to the external data are not picked up and there is no way for me to retrieve them.
i.e. when they navigate to: www.mywebsite.com/myform?recordid=1
I have two options:
If you can help me implement either of these it would be greatly appreciated!
Comment author was deleted
Ok I understand better now, 2 is probably the easiest solution, will look into that.
If you are still interested in how you can return your own entries viewer here are the bits
Angularjs controller:
angujarjs view:
api controller that returns the record data:
Entry model
package manifest
Cheers Tim. Look forward to your response!
Comment author was deleted
Ok added the event RecordFetching on Umbraco.Forms.Data.Storage.RecordStorage
You can upgrade to the latest nightly build to make use of it http://nightly.umbraco.org/UmbracoForms/nightlies/UmbracoForms.Files.4.2.0-WIP.Build.65.zip
OK great thanks!
That works fine for the nightly build :)
any idea when the 4.2.0 build will be officially released? (including nuget)
is working on a reply...