Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I am using below code to create and giving public access but Node is creating and it is giving error
string strDocumentName = "Sample";//DateTime.Now.ToString("yyyy_MM_dd"); DocumentType dt = DocumentType.GetByAlias("TestApplication-Comment"); //author uses a dummy user called CommentWriter User author = User.GetUser(0); Document doc = Document.MakeNew(strDocumentName, dt, author,Node.GetCurrent().Parent.Id); Member myMember = Member.GetCurrentMember(); //add properties doc.getProperty("commentName").Value = myMember.Text; //doc.getProperty("commentBody").Value = tbComments.Text; doc.getProperty("commentID").Value = myMember.Id; int loginDocId = 1479; int errorDocId = 1478; umbraco.cms.businesslogic.web.Access.ProtectPage(true, doc.Id, loginDocId, errorDocId); umbraco.cms.businesslogic.web.Access.AddMembershipRoleToDocument(doc.Id, "Visitors"); doc.Publish(author); umbraco.library.UpdateDocumentCache(doc.Id);
Object reference not set to an instance of an object.
Do you have stack trace info on this error?
Cheers,
/Dirk
Take a look into this thread, perhaps it helps:
http://our.umbraco.org/forum/developers/api-questions/5669-Setting-Public-Access-on-a-node-programatically
Thomas
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Giving Node Public access programatically?
Hi,
I am using below code to create and giving public access but Node is creating and it is giving error
string strDocumentName = "Sample";//DateTime.Now.ToString("yyyy_MM_dd");
DocumentType dt = DocumentType.GetByAlias("TestApplication-Comment");
//author uses a dummy user called CommentWriter
User author = User.GetUser(0);
Document doc = Document.MakeNew(strDocumentName, dt, author,Node.GetCurrent().Parent.Id);
Member myMember = Member.GetCurrentMember();
//add properties
doc.getProperty("commentName").Value = myMember.Text;
//doc.getProperty("commentBody").Value = tbComments.Text;
doc.getProperty("commentID").Value = myMember.Id;
int loginDocId = 1479;
int errorDocId = 1478;
umbraco.cms.businesslogic.web.Access.ProtectPage(true, doc.Id, loginDocId, errorDocId);
umbraco.cms.businesslogic.web.Access.AddMembershipRoleToDocument(doc.Id, "Visitors");
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
Object reference not set to an instance of an object.
Server Error in '/' Application.
Object reference not set to an instance of an object.
Do you have stack trace info on this error?
Cheers,
/Dirk
Take a look into this thread, perhaps it helps:
http://our.umbraco.org/forum/developers/api-questions/5669-Setting-Public-Access-on-a-node-programatically
Thomas
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.