Updating a property using ContentService.Published
I want to update a document property after the page is published with a value from a 3rd party web service.
When I use contentService.SaveAndPublishWithStatus i end up in an infinite loop.
When I use contentService.Save(node, 0); it works fine but then the page is flagged as having unpublished changes and is greyed out to the user which is confusing for them.
How can I set a property value, publish the page and not end up in an infinite loop?
But i am updating a 3rd party web service. I need to do this when the document is published. I don't want to do it when a user may just be saving a draft of the document. My code needs to do 2 things. Update a 3rd party web service when the document is published, then update an Umbraco property with a returned value...
//update 3rd party web service:
string retVal = AppLib.sendPropLinkUmbraco(node.Id, "publish");
//take returned value and update umbraco property
node.SetValue("advertRef", retVal);
Ok, now I understand.
The infinite loop is logical in that case. You ask tell it to publish when publishing tho the event triggers again and again.
What happens if you use the publishing event?
If you do a normal save there it will happen before the actual publishing.
I expect that is the effect you are looking for?
Updating a property using ContentService.Published
I want to update a document property after the page is published with a value from a 3rd party web service.
When I use contentService.SaveAndPublishWithStatus i end up in an infinite loop.
When I use contentService.Save(node, 0); it works fine but then the page is flagged as having unpublished changes and is greyed out to the user which is confusing for them.
How can I set a property value, publish the page and not end up in an infinite loop?
Hi Dan
Try to use Publishing event, have a look at content service events - https://our.umbraco.com/documentation/reference/events/contentservice-events
Alex
As I understand it both Publishing and Published both ignore the "raiseEvents" flag and both end up in an infinite loop so not a solution sadly.
You don't need to save the content at least when you are using ContentSerice.Saving.
for example:
Exactly, Frans, thank you so much.
But i am updating a 3rd party web service. I need to do this when the document is published. I don't want to do it when a user may just be saving a draft of the document. My code needs to do 2 things. Update a 3rd party web service when the document is published, then update an Umbraco property with a returned value...
Ok, now I understand. The infinite loop is logical in that case. You ask tell it to publish when publishing tho the event triggers again and again.
What happens if you use the publishing event? If you do a normal save there it will happen before the actual publishing. I expect that is the effect you are looking for?
Yes, that's perfect! I thought I'd tried the Publishing event but clearly not! Thanks very much for your help.
is working on a reply...