I'm just trying to populate the above field with a propertyAlias of metaDescription. The code below we have working with a site running v6 and it works perfectly.
I'm using V7 and the code is here:
public void SetPropertyOnContent(IContent content, string propertyAlias, string value)
{
content.SetValue(propertyAlias, value);
SaveAndPublishIfAppropriate(content);
}
void SaveAndPublishIfAppropriate(IContent content)
{
if (content.Published)
{
var publishAttempt = ServiceContext.ContentService.SaveAndPublishWithStatus(content);
if (publishAttempt.Success)
{
Console.WriteLine("Successfully published node with id {0}", content.Id);
}
else
{
throw new InvalidOperationException("Failed to publish node with id " + content.Id);
}
}
else
{
ServiceContext.ContentService.Save(content);
Console.WriteLine("Successfully saved unpublished node with id {0}", content.Id);
}
}
I think this may be a bug since the big thing in v7 is the new ui + improvements of the installer and other things. Don't think there should be any changes to the underlying API. I could be wrong but I think it's a good idea to file a bug report at http://issues.umbraco.org/issues.
ContentService SetValue on a textfield property type failing
Hi I have an instance IContent with a propertyalias of metaDescription.
In the content service I'm calling content.SetValue("metaDescription", "test");
and then calling ServiceContext.ContentService.SaveAndPublishWithStatus(content)
The result is coming back with Umbraco.Core.Publishing.PublishStatusType.FailedContentInvalid
when I'm inserting a string in to a textfield..
Just wondering if this was a legitimate bug?
Hi Tom
What version of Umbraco are you using? is it 6 or 7?
And have you consulted the documentation on using the contentservice here http://our.umbraco.org/documentation/Reference/Management-v6/Services/?
If so...could you perhaps show your code so it's a lot easier for people to help you out?
Looking forward to hearing from you.
Cheers,
Jan
Hi Jan,
Thanks for the reply.
I'm just trying to populate the above field with a propertyAlias of metaDescription. The code below we have working with a site running v6 and it works perfectly.
I'm using V7 and the code is here:
Hi Tom
I think this may be a bug since the big thing in v7 is the new ui + improvements of the installer and other things. Don't think there should be any changes to the underlying API. I could be wrong but I think it's a good idea to file a bug report at http://issues.umbraco.org/issues.
Cheers,
Jan
Thanks Jan will do.
is working on a reply...