On ExtractingProperty, the PersistenceManager's GetNodeId method returns 0
We are using the nightly build of Courier (v2.11.122).
We implemented a Custom PropertyDataResolverProvider.
Because we have a Custom datatype called "LinkPicker" to be able to create a hyperlink to another content node in Umbraco. To enable the translation of the linked node in the other environment where this gets extracted, we add the Guid from the linked node as extra field.
In the PackagingProperty method we save the LinkPicker as json via the following code:
public override void PackagingProperty(Item item, ContentProperty propertyData) { //1. Get the LinkPicker var linkPicker = JsonHelper.DeserializeJsonString<UmbrellaLinkPicker>(propertyData.Value.ToString()); if (linkPicker != null && linkPicker.ContentId > 0) { //1. Get the Guid from Umbraco With Type Content var umbracoGuid = PersistenceManager.GetDefault(this.ExecutionContext) .GetUniqueId(linkPicker.ContentId, NodeObjectTypes.Document); //2. Get the new Value (json) for the linkPicker along with the Guid from Umbraco var courierLinkPicker = new CourierLinkPicker { UmbracoGuid = umbracoGuid, LinkPicker = linkPicker }; // The new value is the LinkPicker with the Guid of the Linked Content // When extracting, we can find the new environment's NodeId from this Guid propertyData.Value = JsonHelper.SerializeJsonString(courierLinkPicker);
//3. Add the dependency for the linked Content because Umbraco won't do this automatically item.Dependencies.Add(umbracoGuid.ToString(), _linkPickerProviderId); } base.PackagingProperty(item, propertyData); }
The output of the PackagingProperty method would be something like:
public override void ExtractingProperty(Item item, ContentProperty propertyData) { // Get the LinkPicker and its linked Guid (wrapper in CourierLinkPicker) var courierlinkPicker = JsonHelper.DeserializeJsonString<CourierLinkPicker>(propertyData.Value.ToString()); if (courierlinkPicker != null && courierlinkPicker.LinkPicker != null && courierlinkPicker.UmbracoGuid != Guid.Empty) { // Extract LinkPicker // Resolve the Umbraco Guid to this new environment's NodeId with type Document
var newContentNodeId = PersistenceManager.GetDefault(this.ExecutionContext).GetNodeId(courierlinkPicker.UmbracoGuid, NodeObjectTypes.Document);
var umbrellaLinkPicker = courierlinkPicker.LinkPicker; if (newContentNodeId > 0) { // Update the linked Content with the new ContentId umbrellaLinkPicker.ContentId = newContentNodeId; } }
Now here's the catch:
When the linked node is of the DocumentType Page it works as excepted, the "local" nodeId gets retreived.
We use the concept of subnodes to enable the Back Office user to add content blocks to a Page.
We call them Widgets.
When the linked node is a Widget the returned nodeId is 0 (zero).
What we know is that Page has a MVC View and Controller.
The widgets don't, because it's the Page has the responsibility to render the widgets.
! Also we test the extracting functionality by deleting the DB, thus simulating that the new environment has no content, documentypes, etc yet.
So maybe the issue is that the target node does not exist on the target environment at the moment that the source page is extracted??
The target node is added as dependency to the source node, so I would expect that this would prevent that from happening?
Many thanks in advance for any help regaring this issue!
I'm not sure this is doing what you think it's doing. From what you have here it doesn't look like the item (link picker type) ever gets created on the target environment. If you'll attach the solution (on the issue thread) you have we can do a little debugging to help you see what might be missing...and, of course, it'll help us identify if there is an issue on the Courier side too...so thanks
This is with 7.2.1, right?
Also, are you with a Gold Partner or have a Confidence agreement we can log this to?
On ExtractingProperty, the PersistenceManager's GetNodeId method returns 0
We are using the nightly build of Courier (v2.11.122).
We implemented a Custom PropertyDataResolverProvider.
Because we have a Custom datatype called "LinkPicker" to be able to create a hyperlink to another content node in Umbraco. To enable the translation of the linked node in the other environment where this gets extracted, we add the Guid from the linked node as extra field.
In the PackagingProperty method we save the LinkPicker as json via the following code:
The output of the PackagingProperty method would be something like:
On Extracting we use this code:
Now here's the catch:
When the linked node is of the DocumentType Page it works as excepted, the "local" nodeId gets retreived.
We use the concept of subnodes to enable the Back Office user to add content blocks to a Page.
We call them Widgets.
When the linked node is a Widget the returned nodeId is 0 (zero).
What we know is that Page has a MVC View and Controller.
The widgets don't, because it's the Page has the responsibility to render the widgets.
! Also we test the extracting functionality by deleting the DB, thus simulating that the new environment has no content, documentypes, etc yet.
So maybe the issue is that the target node does not exist on the target environment at the moment that the source page is extracted??
The target node is added as dependency to the source node, so I would expect that this would prevent that from happening?
Many thanks in advance for any help regaring this issue!
Kind Regards,
Jan.
@jan
I'm not sure this is doing what you think it's doing. From what you have here it doesn't look like the item (link picker type) ever gets created on the target environment. If you'll attach the solution (on the issue thread) you have we can do a little debugging to help you see what might be missing...and, of course, it'll help us identify if there is an issue on the Courier side too...so thanks
This is with 7.2.1, right?
Also, are you with a Gold Partner or have a Confidence agreement we can log this to?
Thanks
Hey Paul,
The company for which we are developing this project is Wolters Kluwer Belgium, and they do have a Confidence Agreement.
We are currently using Umbraco 7.1.8
It does work when this LinkPicker points to a Page, that's why I'm puzzled why it doesn't work for the other 'targets'.
I'll see to it that we can provide what you need.
I think about:
- The Linkpicker editor (in App_Plugins)
- The code (LinkPicker class, DataResolverProvider)
- .. ?
Let me know if you miss something by then.
Thanks!
is working on a reply...