on 11-08-2012 2:41 PM
Hi All,
I am implementing a workflow on UDO1 that is going to get an approval group from an extension on the UDO1 type called approver_1.
I am using the following prescript but keep getting the error A reflection error occurred accessing the object.
import com.sap.odp.api.doccommon.userdefined .*;
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.*;
level1ApproverExtName = "approver_1";
logMsg = Logger.createLogMessage(session);
typeHome = IBeanHomeLocator.lookup(session, doc.getDocTypeReference());
typeBean = typeHome.find(doc.getDocTypeReference());
principal = typeBean.getExtensionField(level1ApproverExtName).get();
if (hasValue(principal))
{
// Add the user account as the approver
addApprover(principal,new CollaboratorApprovalRuleType(0));
// log details
logMsg.setLogMessage("Added user: " + principal.getDisplayName() + " as approver");
Logger.info(logMsg);
}
Does anyone know what might be causing this issue?
Many thanks
Dan
Hi Dan,
Is your approver a user or a group? If it is a user, then the addApprover method should be addApprover(principal). The CollaboratorApprovalRuleType parameter should be passed only when you are dealing with groups.
Hope this helps.
Regards,
Vikram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shyam,
I tried your suggest code but I still got the reflection error. I agree that it seems to not be picking up the principal.
Should the typeBean be set in a different way when using UDO? I have not had any issues on other documents using this method for both approval prescript and scripting.
Thanks
Dan
Dan,
I've made some changes to code and its working in my system. I hope this should resolve your issue.
import com.sap.odp.api.doccommon.userdefined .*;
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.*;
import com.frictionless.api.doc.collaboration.CollaboratorApprovalRuleType;
import com.frictionless.doc.collaboration.CollaboratorApprovalRule;
RULE_TYPE = CollaboratorApprovalRule.ALL;
level1ApproverExtName = "approver_1";
principal = doc.getExtensionField(level1ApproverExtName).get();
if (hasValue(principal))
{
addApprover(principal,new CollaboratorApprovalRuleType(RULE_TYPE));
}
Regards,
Shyam
Hi Shyam,
I have simplified the requirement to make this issue easier to solve, my extension field is now on the UDO document.
I tried your suggestion but it did not work, I think this is due to importing packages with frictionless in the name, I am in version 9 so all the packages have sap in the name.
I am trying the following code and it is not giving me an error in the logs and it is entering the correct group into the log message, however it is not adding the group as an approver! This code is working perfectly in the project module in the same system.
import com.sap.odp.api.doccommon.userdefined .*;
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.*;
level1ApproverExtName = "approvergrp";
logMsg = Logger.createLogMessage(session);
principal = doc.getExtensionField(level1ApproverExtName).get();
if (hasValue(principal))
{
// Add the user account as the approver
addApprover(principal,new CollaboratorApprovalRuleType(0));
// log details
logMsg.setLogMessage("Added user: " + principal.getDisplayName() + " as approver");
Logger.info(logMsg);
}
Does anyone have any ideas about what may be causing the group not to be added to the UDO?
Many thanks
Dan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.