cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow prescript can not find approver

Former Member
0 Kudos

Hi,

I am using SAP Sourcing 7 and am trying to implement a basic project one gate approval using an approver chosen in an extension field.

My problem is that the prescript code will not add the approver to the collaborator list, only the process owner is added when I move to the approval phase. The log is showing a NullPointerException which indicates to me that the prescript code is not able to get the user from my extension field.

I created an extension reference with class name u201CUser Accountu201D and then created the extension field on the Project header tab with internal name u201CLevel1Appu201D with object reference to u201CUser Accountu201D.

The Prescript I am using is:

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.ibean.*;

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

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

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

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

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

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

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

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

// Step 1: Add level 1 approver from Project Type

// These hold the name of the extension fields we are concerned

// with.

level1ApproverExtName = "Level1App";

// Create a logger for messaging

logMsg = Logger.createLogMessage(session);

// doc is a ProjectIBeanIfc

typeHome = IBeanHomeLocator.lookup(session, doc.getDocTypeReference());

typeBean = typeHome.find(doc.getDocTypeReference());

// Level 1 Approver

principal = typeBean.getExtensionField(level1ApproverExtName).get();

if (hasValue(principal))

{

// Add the user account as the approver

addApprover(principal);

// log details

logMsg.setLogMessage("Added user: " + principal.getDisplayName() + " as approver");

Logger.info(logMsg);

}

Does anyone know what is wrong with this causing it to not find the user in the Level1App extension field?

Many thanks!

Dan

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Dan,

If I understand correctly, the Level 1 Approver extension is on the Project Header tab and not on the Document Type. In that case, you need to do doc.getExtensionField(level1ApproverExtName).get();

Hope this helps.

Regards,

Vikram

Former Member
0 Kudos

Hi Vikram,

Thank you for your help with this, my workflow is now working!

I had not considered placing an extension on the type rather than the document.

Many thanks

Dan

Answers (0)