Hello, I'm trying to save my IContent called child, but on this line(contentService.SaveAndPublish(child);) I get the following error: Object reference not set to an instance of an object.
if (child.HasProperty("navn"))
{
child.SetValue("navn", worker.Name.ToString(), "da-dk");
}
contentService.SaveAndPublish(child);
This is how I define my contentService: IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
And I'm finding the children like this:
long totalChildren;
IEnumerable<IContent> children = contentService.GetPagedChildren(filialsParent.Id, 0, 100, out totalChildren);
Have you tried with setting the same culture on the SaveAndPublish event?
contentService.SaveAndPublish(child, "da-dk");
But if you create a new multilangual content, then you cant SaveAndPublish it.
// Cannot save content with an empty name.
var content = _contentService.Create("contentName", 1025, "contentTypeAlias");
_contentService.SaveAndPublish(content, "da-dk");
Unable to use SaveAndPublish from ContentService
Hello, I'm trying to save my
IContent
calledchild
, but on this line(contentService.SaveAndPublish(child);
) I get the following error:Object reference not set to an instance of an object.
This is how I define my
contentService
:IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
And I'm finding the children like this:
ยด Can someone point out what is wrong here?
If you are using one of the Umbraco controllers (Surface, Mvc or Api controller) you should be able to use something like this:
The
Services
object is available in the controllers already and it includes singletons for all the services.Hi Carsten.
Have you tried with setting the same culture on the SaveAndPublish event?
But if you create a new multilangual content, then you cant SaveAndPublish it.
is working on a reply...