|
Home > Archive > Microsoft Content Management Server > April 2006 > updating a mcms posting (using CmsApplicationContext)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
updating a mcms posting (using CmsApplicationContext)
|
|
| rajsrawat@gmail.com 2006-04-27, 7:27 am |
| I need to write an automation script (to update MCMS postings via a
console application.)
When I try to do an update it needs the state to be in saved .. mode,
but currentPost.State is read only property
How can I change the state to saved
error I'm getting
Microsoft.ContentManagement.Publishing.CmsInvalidObjectStateException:
Invalid state for submitting posting. A posting can only be submitted
if its state is 'New', 'Saved', 'Editor Declined' or 'Moderator
Declined'. ---> System.Runtime.InteropServices.COMException
(0x80041BC7)
at
Microsoft.ContentManagement.Interop.Publishing.IRcwPosting.Submit()
at Microsoft.ContentManagement.Publishing.Posting.Submit()
My code:
CmsApplicationContext cmsAppCtx = new CmsApplicationContext();
try
{
cmsAppCtx.AuthenticateAsCurrentUser
(PublishingMode.Update);
Channel cmsChannelToEdit = null;
cmsChannelToEdit =
cmsAppCtx.Searches.GetByPath("/Channels/mysite/aboutus/news") as
Channel;
foreach( Posting currentPost in
cmsChannelToEdit.Postings)
{
currentPost.Submit();
currentPost.Approve();
}
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
cmsAppCtx.CommitAll();
cmsAppCtx.Dispose();
}
(ref:
http://download.microsoft.com/downl...9B-A9F450FD69C1
)
| |
| Stefan [MSFT] 2006-04-27, 7:27 am |
| Hi,
as soon as you save the content it will automatically change to "Saved".
If nothing has changed the state will not change to Saved.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
<rajsrawat@gmail.com> wrote in message
news:1145358920.303666.125510@v46g2000cwv.googlegroups.com...
>I need to write an automation script (to update MCMS postings via a
> console application.)
>
> When I try to do an update it needs the state to be in saved .. mode,
> but currentPost.State is read only property
>
> How can I change the state to saved
>
>
>
> error I'm getting
>
>
>
> Microsoft.ContentManagement.Publishing.CmsInvalidObjectStateException:
> Invalid state for submitting posting. A posting can only be submitted
> if its state is 'New', 'Saved', 'Editor Declined' or 'Moderator
> Declined'. ---> System.Runtime.InteropServices.COMException
> (0x80041BC7)
>
> at
> Microsoft.ContentManagement.Interop.Publishing.IRcwPosting.Submit()
>
> at Microsoft.ContentManagement.Publishing.Posting.Submit()
>
>
>
>
>
> My code:
>
>
>
> CmsApplicationContext cmsAppCtx = new CmsApplicationContext();
>
>
>
> try
>
> {
>
> cmsAppCtx.AuthenticateAsCurrentUser
> (PublishingMode.Update);
>
>
>
> Channel cmsChannelToEdit = null;
>
>
> cmsChannelToEdit =
> cmsAppCtx.Searches.GetByPath("/Channels/mysite/aboutus/news") as
> Channel;
>
>
>
> foreach( Posting currentPost in
> cmsChannelToEdit.Postings)
>
> {
>
>
>
> currentPost.Submit();
>
> currentPost.Approve();
>
> }
>
>
>
> }
>
> catch(Exception ex)
>
> {
>
>
>
> Console.WriteLine(ex.ToString());
>
> }
>
> finally
>
> {
>
> cmsAppCtx.CommitAll();
>
> cmsAppCtx.Dispose();
>
> }
>
>
>
> (ref:
> http://download.microsoft.com/downl...9B-A9F450FD69C1
> )
>
|
|
|
|
|