Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

workflow endless loop , is there a solution ?

  Asked By: Rachel    Date: Dec 18    Category: Sharepoint    Views: 12168

I'm new in SP world and still on my first steps,
but im facing a problem when working on workflows with the page
this is my problem,
when i Create a Sharepoint custom list and enable content approval
on the list. I added the Approval workflow to the list, and specify
that you want the workflow to automatically start whenever the list
item changes. Every time that list item changes, I want the
approver to get an e-mail and be able to look at it and hit the
approve/reject button on it - a very reasonable thing in my
opinion. But it doesn't work! It results in an endless loop.

I guess that this is the reason..
When someone makes a change to the list item, the approval status
gets set to Pending and the workflow automatically kicks off.
Good. Now the approver gets the e-mail, views the list item and
approves it. Good. That sets the approval status to Approved. But
then guess what? Because the status got set to Approved by the
Approve/Reject page, Sharepoint sees that as a "change" to the item
and then sets the approval status back to
Pending!!!! You can never get it set to Approved because it gets in
an endless loop of Pending-Approved-Pending ..



1 Answer Found

Answer #1    Answered By: Sumitra 2004     Answered On: Dec 18

Perhaps you could implement an event handler that triggers on
ItemChanging and determines whether the user is just changing the
approval status or something else. If they are just setting the status
to approved you set a hidden Boolean property called something like
ObtainApproval to false otherwise you set the Boolean to true. When the
workflow fires, it first checks the ObtainApproval property; if set to
true it processes just as it does today but if it is set to false you
know that the previous change was only to approve the change and the
workflow silently completes.

I have a nagging feeling that you will also have to handle ItemChanging
firing twice when a moderated Item is approved, but I'd have to test to
be sure.

Didn't find what you were looking for? Find more on workflow endless loop , is there a solution ? Or get search suggestion and latest updates.