I have a user control setup as a custom data type using the IUsercontrolDataEditor. It needs know one of the other property values of the document. I was doing this the NodeFactory.GetCurrent().GetProperty("...") but this wont get me the lasted value if the document is only saved and not published.
NodeFactory only accesses published data. To access "saved" data you'll want to use the Document API. Typically when you are working on the backend you'll always want to use the Document API for this reason.
The usage is pretty similar:
using umbraco.cms.businesslogic.web;
Document d = new Document(1234); string x = d.getProperty("...").Value;
Note there is no equivalent of .GetCurrent() to get the current document, but if in the backend you can grab it from the 'id' querystring, something like:
Document d = new Document(Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]));
oops, I was too slow to answer :) and as Tom correctly points out to get the current node from a custom datatype you'll need to query the QueryString (or use the uComponents uQuery.GetCurrentNode() which will first attempt to use the node factory and if it's not available then will try to take it from the QueryString)
Accessed saved property from custom data type
I have a user control setup as a custom data type using the IUsercontrolDataEditor. It needs know one of the other property values of the document. I was doing this the NodeFactory.GetCurrent().GetProperty("...") but this wont get me the lasted value if the document is only saved and not published.
How can I get the most up to date value?
Hi,
NodeFactory only accesses published data. To access "saved" data you'll want to use the Document API. Typically when you are working on the backend you'll always want to use the Document API for this reason.
The usage is pretty similar:
Note there is no equivalent of .GetCurrent() to get the current document, but if in the backend you can grab it from the 'id' querystring, something like:
Hope this helps,
Tom
Hi,
You can use the Document API as this will work with the values from the database, (the NodeFactory works with the values from the published XML).
HTH,
Hendy
oops, I was too slow to answer :) and as Tom correctly points out to get the current node from a custom datatype you'll need to query the QueryString (or use the uComponents uQuery.GetCurrentNode() which will first attempt to use the node factory and if it's not available then will try to take it from the QueryString)
is working on a reply...