Skip to Content
0
Apr 17, 2012 at 02:28 AM

Postscript Script Error: Error moving the Workflow Phase from Legal Review -->Supplier Draft or from Legal Review -->Draft

18 Views

Hi Experts,

I am facing the following issue while moving the Workflow phase from Legal Review Supplier Draft or from Legal Review à Draft.

The following are the phases we currently have:

  1. Draft.
  2. Legal Review (Workflow Attached)
  3. Supplier Draft
  4. Waiting for Internal Approval.
  5. Executed.
  6. When I am moving the phase DraftàLegal Review . I am expecting once the document is approved, it should move to Supplier Draft. But its saying ‘Error Moving to Supplier Draft Phase, Supplier Draft is not a valid next or previous phase’. Same way when its rejected it should move to ‘Draft’ Phase.

When I checked the code by putting the log message in the Post Script, I found that the Post Script is getting executed twice. I am clueless why it’s getting executed twice.

In the post script for the 1st time its saying the current phase is ‘Draft’ and in the next time its saying the current phase is ‘NULL’.

Following is the code for Post Script.

import com.sap.odp.api.common.exception.*;

import com.sap.odp.api.common.log.Logger;

import com.sap.odp.api.common.platform.*;

import com.sap.odp.api.common.types.*;

import com.sap.odp.api.doc.collaboration.*;

import com.sap.odp.api.doc.IapiDocumentLockManager;

import com.sap.odp.api.doccommon.masterdata.*;

import com.sap.odp.api.ibean.*;

import com.sap.odp.api.util.*;

import com.sap.odp.api.workflow.*;

import com.sap.odp.api.projects.*;

import com.sap.odp.api.common.log.*;

import com.sap.odp.api.ibean.*;

import com.sap.odp.api.usermgmt.masterdata.*;

import com.sap.odp.api.doc.collaboration.*;

// The final step of the approval process moves

// the phase of the Project to Approved

// (if all approvals were made) or back to xxx

// (if there was a denial).

// Create a logger for messaging

logMsg = Logger.createLogMessage(session);

// If we are not approved, then change the phase backward

if (getApprovalStatus() != APPROVED)

{

home = doc.getIBeanHomeIfc();

home.upgradeToEdit(doc);

logMsg.setLogMessage("-----Current Phase is:"+doc.getCurrentPhase().getDisplayName()+"-----------");

Logger.error(logMsg);

if (!doc.getCurrentPhase().equals("Draft"))

{

try

{

home.changePhase(doc,"Draft");

}

catch(e)

{

logMsg.setLogMessage(e.toString());

logMsg.setException(e);

Logger.error(logMsg);

}

}

}

// If we are approved, change the phase forward

if (getApprovalStatus() == APPROVED)

{

home = doc.getIBeanHomeIfc();

home.upgradeToEdit(doc);

try

{

home.changePhase(doc,"Supplier Draft");

}

catch(e)

{

logMsg.setLogMessage(e.toString());

logMsg.setException(e);

Logger.error(logMsg);

}

}

logMsg.setLogMessage("Completed Workflow");

Logger.error(logMsg);

Looking forward for your help.

Thanks,

Ritik