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:
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