Umbraco (VERY STRANGE) SaveAndPublishWithStatus(data) saving to the wrong parentId
Hi Guys,
Umbraco version 7.4.3 assembly: 1.0.5948.18141
A very strange issue. Basically the save and publish method is not saving to the parentId I passed in to the data. I have run multiple tests and this is happening for sure.
Here is a very basic version of my code
public static int InsertJob(int parentId, Job job)
{
var contentService = ApplicationContext.Current.Services.ContentService;
var name = job.Title;
Node jobsListFolder = ContentManager.GetNodeByNodeTypeAlias(parentId, "jobsListFolder");
var data = contentService.CreateContent(name, jobsListFolder.Id, "job", 0); //i have checked and the correct node is got here witht he correct nodeId
data.SetValue("senderName", job.SenderName);
data.SetValue("senderId", job.SenderId);
// save and publish
contentService.SaveAndPublishWithStatus(data);
return data.Id;
}
Further information...
I have two docTypes (folders) with the type jobsListFolder. This is where I am trying to insert the data.
When I run the insert using the parentId 3633 it actually gets saved into 4124. I have checked and checked again and then again and the correct parentId is getting passed into the data thats getting saved (parentId:3633) but it is for sure getting saved into parentId: 4124 (VERY STRANGE)
I tried this a number of times and always the same effect.
Whats even more strange is I deleted parentId: 4124 which it was saving into my mistake and tested saving again. This time it was saving in the correct node (parentId: 3633)
I then tested adding another parent node of this type and then tested saving again with the exact same data as always. Again it was saving into the wrong parent (the new one I created) rather than the parentId I was passing in.
Its got to be somehow related to the two parents been the same node type. I have never seen this in the past and just cant figure out whats happening.
I tried to re-publish the entire site which didn't fix the issue.
Feel a little stupid. I finally figure it out. It was in-fact saving to the correct folder but then I found Published ApplicationEventHandler that was then moving it to the wrong folder.
Some routine maintenance script which I forgot about.
I think the lesson to be learned here is don't forget about the events running in the background you coded last year.
Umbraco (VERY STRANGE) SaveAndPublishWithStatus(data) saving to the wrong parentId
Hi Guys,
Umbraco version 7.4.3 assembly: 1.0.5948.18141
A very strange issue. Basically the save and publish method is not saving to the parentId I passed in to the data. I have run multiple tests and this is happening for sure.
Here is a very basic version of my code
Further information...
I have two docTypes (folders) with the type jobsListFolder. This is where I am trying to insert the data.
Example...
Folder1 - Umbraco Node Id: 3633 Folder2 - Umbraco Node Id: 4124
When I run the insert using the parentId 3633 it actually gets saved into 4124. I have checked and checked again and then again and the correct parentId is getting passed into the data thats getting saved (parentId:3633) but it is for sure getting saved into parentId: 4124 (VERY STRANGE)
I tried this a number of times and always the same effect.
Whats even more strange is I deleted parentId: 4124 which it was saving into my mistake and tested saving again. This time it was saving in the correct node (parentId: 3633)
I then tested adding another parent node of this type and then tested saving again with the exact same data as always. Again it was saving into the wrong parent (the new one I created) rather than the parentId I was passing in.
Its got to be somehow related to the two parents been the same node type. I have never seen this in the past and just cant figure out whats happening.
I tried to re-publish the entire site which didn't fix the issue.
Thanks in advanced for any help.
Kind Regards
David
Oh my,
Feel a little stupid. I finally figure it out. It was in-fact saving to the correct folder but then I found Published ApplicationEventHandler that was then moving it to the wrong folder.
Some routine maintenance script which I forgot about.
I think the lesson to be learned here is don't forget about the events running in the background you coded last year.
Sorry about that :(
is working on a reply...