cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can not lock document in postscript (in workflow)

Former Member
0 Likes
217

Hi Experts,

     I have a requirement to move document's phase to 'Endorsed' and lock the document when all endorsers endorse the document in the workflow. I put below script which is to move the phase and lock the document in the postscript of  the End Of Approval stage. So i tested it and found that the phase was moved to 'Endorsed',but the doument did not get locked. It seems that the document was locked in the postscript,but when the document went out from the workflow the workflow engine released the lock automactically. Is there another way to implement on this requirement?

---------------------------------------------------------------------------------------------------------------------------------------------

if (getApprovalStatus() == APPROVED)

{

    home = doc.getIBeanHomeIfc();

if(doc.getCurrentPhase() == null || !doc.getCurrentPhase().getDisplayName(session).equals("Endorsed")){

  home.upgradeToEdit(doc);

  try

   {

   home.changePhase(doc,"Endorsed");

   IapiDocumentLockManager.lockDocument(session, doc); 

   }

  catch(e)

   {

   logMsg.setLogMessage(e.toString());

   logMsg.setException(e);

   Logger.error(logMsg);

   }

}

}

-----------------------------------------------------------------------------------------------------------------------------------------------------

Thank you in advance

Noppong Jinbunluphol

View Entire Topic
former_member89217
Contributor
0 Likes

Yes you can't use a post script to accomplish this requirement since the Script executes PRIOR to releasing the Lock on the document.  One way to do this is a regular script that triggers on a post phase change.  This script will look for the Endorsed phase and when it is endorsed, apply the document lock.

This should work fine.

Regards,

Gary

Former Member
0 Likes

Hi Gary,

    Thank you for your answer. But i put the the logic to change the phase inside the PostScrip too. It mean tha the PostPhaseChange script must be executed inside the workflow as well. BTW, i tried to lock the document on the DocumentLoad script, but it did not work. I got the recursive execution on DocumentLoad script.

Thank you

Noppong

former_member89217
Contributor
0 Likes

Yes this is a bit tricky.  So we have two ways forward that I can think of off hand.  You should be able to use field level locks.  These should persist even after the document is unlocked.  You could try this with a couple of fields and then apply to all that matter.  Second option would be to have a special toolbar script and allow certain admin users to manually lock (and unlock the document) from a normal user standpoint this would be OK it would require some sort of report to clue in the admin user to perform the locking.