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
I'm using ContentPublished event to programmatically change the value of a property with:
node.SetValue("property", 0);
This works fine but the new value of the property is not saved. How do I do that?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Hi Roger,
You need to use the ContentService api.
See the following reference: https://our.umbraco.org/documentation/reference/management/services/contentservice
If you just want to save and not publish:
ApplicationContext.Current.Services.ContentService.Save(IContent node)
If you want to save and publish:
ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(IContent node)
Good luck!
Regards
Craig
Hi Roger
ContentPublished event raised when ContentService.Publish is called in the API and after data has been published. So you have to call Publish method or Save after node.SetValue("property", 0);
Another possibility is to use Publishing event.
Thanks,
Alex
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Save a node programmatically
I'm using ContentPublished event to programmatically change the value of a property with:
node.SetValue("property", 0);
This works fine but the new value of the property is not saved. How do I do that?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Hi Roger,
You need to use the ContentService api.
See the following reference: https://our.umbraco.org/documentation/reference/management/services/contentservice
If you just want to save and not publish:
If you want to save and publish:
Good luck!
Regards
Craig
Hi Roger
ContentPublished event raised when ContentService.Publish is called in the API and after data has been published. So you have to call Publish method or Save after node.SetValue("property", 0);
Another possibility is to use Publishing event.
Thanks,
Alex
is working on a reply...