posting.moveto
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > posting.moveto




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    posting.moveto  
Cat


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-08-04 12:48 PM

I am trying to move expired postings using moveto. I've tried
everything I can and nothing seems to work. I could copyto but when I
tried to delete the posting I got the same error.

"Invalid mode for update.  The requested action modifies the state of
an object and can only be performed when the session is in the
'Update' mode."

Here's my code:

Dim cmsContext As CmsHttpContext = CmsHttpContext.Current
Dim AppContext As CmsApplicationContext = New CmsApplicationContext
AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)

If cmsContext.Channel.Name = "Vacancies" Then
cmsContext.SessionSettings.AutoFilterHidden = False
Dim ch As Channel = cmsContext.Channel
Dim pCol As PostingCollection
pCol = ch.Postings
Dim p, pMove As Posting
For Each p In pCol
Dim pDisplayName As String = p.DisplayName & p.UrlModeUpdate
If p.State = PostingState.Expired Then
Dim chDestination As Channel = cmsContext.Searches.GetByPath("URL")
If (AppContext.Mode = PublishingMode.Update And p.CanMove) Then
p.MoveTo(chDestination)
If Err.Number = 0 Then
Call cmsContext.CommitAll()
End If
End If
End If
Next
cmsContext.SessionSettings.AutoFilterHidden = True
End If

Any Ideas?

Cheers
Cat





[ Post a follow-up to this message ]



    Re: posting.moveto  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-08-04 10:49 PM

Hi Cat,

no wonder!
You are using from the CmsHttpContext and not from the
CmsApplicationContext.
Mean the ch object is taken from the CmsHttpContext and not from the
CmsApplicationContent

And the CmsHttpContext is most likely not in update mode.

Please retrieve all object from the AppContext and not from the cmsContext
and your code will work:

Dim cmsContext As CmsHttpContext = CmsHttpContext.Current
Dim AppContext As CmsApplicationContext = New CmsApplicationContext
AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)

If cmsContext.Channel.Name = "Vacancies" Then
AppContext.SessionSettings.AutoFilterHidden = False
Dim ch As Channel =
AppContext.Searches.GetByGuid(cmsContext.Channel.Guid) as Channel;
Dim pCol As PostingCollection
pCol = ch.Postings
Dim p, pMove As Posting
For Each p In pCol
Dim pDisplayName As String = p.DisplayName & p.UrlModeUpdate
If p.State = PostingState.Expired Then
Dim chDestination As Channel = AppContext.Searches.GetByPath("URL")
If (AppContext.Mode = PublishingMode.Update And p.CanMove) Then
p.MoveTo(chDestination)
If Err.Number = 0 Then
Call AppContext.CommitAll()
End If
End If
End If
Next
AppContext.SessionSettings.AutoFilterHidden = True
End If


Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Cat" <catriona.morrison@ced.glasgow.gov.uk> wrote in message
news:d75afc34.0409080529.20d96ba5@posting.google.com...
> I am trying to move expired postings using moveto. I've tried
> everything I can and nothing seems to work. I could copyto but when I
> tried to delete the posting I got the same error.
>
> "Invalid mode for update.  The requested action modifies the state of
> an object and can only be performed when the session is in the
> 'Update' mode."
>
> Here's my code:
>
> Dim cmsContext As CmsHttpContext = CmsHttpContext.Current
> Dim AppContext As CmsApplicationContext = New CmsApplicationContext
> AppContext. AuthenticateAsCurrentUser(PublishingMode
.Update)
>
> If cmsContext.Channel.Name = "Vacancies" Then
>  cmsContext.SessionSettings.AutoFilterHidden = False
>  Dim ch As Channel = cmsContext.Channel
>  Dim pCol As PostingCollection
>  pCol = ch.Postings
>  Dim p, pMove As Posting
>  For Each p In pCol
>   Dim pDisplayName As String = p.DisplayName & p.UrlModeUpdate
>   If p.State = PostingState.Expired Then
>    Dim chDestination As Channel = cmsContext.Searches.GetByPath("URL")
>    If (AppContext.Mode = PublishingMode.Update And p.CanMove) Then
>     p.MoveTo(chDestination)
>     If Err.Number = 0 Then
>      Call cmsContext.CommitAll()
>     End If
>    End If
>   End If
>  Next
>  cmsContext.SessionSettings.AutoFilterHidden = True
> End If
>
> Any Ideas?
>
> Cheers
> Cat







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:56 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register