I want to be able to change values in my created documents programmatically. At the moment I use this code, with no significant amount of success ;) What seems to be the problem? No errors, just no effect on the backend!
using umbraco.presentation.nodeFactory; using umbraco.cms.businesslogic.web; using umbraco.BusinessLogic;
namespace MySite { public partial class ChangeInfo : System.Web.UI.UserControl
protected void UpdateDocument() { DocumentType dt = DocumentType.GetByAlias("Customer"); User author = User.GetUser(0); Document doc = new Document(GetCurrentUser().Id);
Document does not change on save and publish
Hi,
I want to be able to change values in my created documents programmatically. At the moment I use this code, with no significant amount of success ;) What seems to be the problem? No errors, just no effect on the backend!
You're supposed to be referencing the node ID in this line, not the user.
You need something like (replace 1029 with the node if you need to edit)
Also, you don't need doc.Save (I believe) and this line doesn't do anything in your code
DocumentType dt = DocumentType.GetByAlias("Customer");
http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties
Rich
This is my method for retrieving the node which contains the ID used in Document(GetCurrentUser().Id).
It is not a user ID. It does retrieve the correct Id.
I found that it does update the properties if I set the value in the code like
doc.getProperty("companyName").Value = "Company A";
Although from a textbox it does not work ....why!?
doc.getProperty("companyName").Value = CompanyTxtBox.Text;
Did you try to step through / debug your code?
Rich
I don't know how to attatch debugger to my project since I copy my files from the projetct folder to my umbraco installation folder.
is working on a reply...