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

Contract Documents approval workflow prescript code to add approver

Former Member
0 Kudos
247

Hello experts,

I am new to workflow scripting,I need a sample prescript code to add approver in the workflow for contract document approval test.

Thanks and regards,

Kubra

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Error description is given below

2011-09-30 00:11:06.114	INFO	local4			Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon			Start Of Workflow
2011-09-30 00:11:06.161	INFO	local4			Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon			in the Workflow
2011-09-30 00:11:06.161	INFO	local4			Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon			end Of Workflow
2011-09-30 00:11:06.192	ERROR	local4	WorkflowEngineDaemon	processHook	Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon	com.frictionless.api.common.exception.ApplicationException: Restricted To User is set to true on the Collaborator Role Object, so it can only be used with a user principal.	AssociatedAttribute=COLLABORATORS - SourceBo=1258291201:1004:workflow - ValidatingParent=1258291201:1004:workflow - com.frictionless.api.common.exception.ApplicationException: At least one of the items above is invalid. Mouse over the highlighted area for more details.| at com.frictionless.api.common.exception.ChainedExceptionFactory.createApplicationException(ChainedExceptionFactory.java:90)| at com.frictionless.common.db.PersistentBo.createApplicationException(PersistentBo.java:3160)| at com.frictionless.doc.collection.GeneralCollnBo.createApplicationException(GeneralCollnBo.java:324)| at com.frictionless.doc.collection.GeneralCollnBo.createApplicationException(GeneralCollnBo.java:336)| at com.frictionless.doc.collection.SubCollnBo.validateCollection(SubCollnBo.java:1264)| at com.frictionless.doc.ContainerBo.execValidate(ContainerBo.java:3737)| at com.frictionless.doc.BizDocBo.execValidate(BizDocBo.java:1965)| at com.frictionless.doc.ContainerBo.validate(ContainerBo.java:1257)| at com.frictionless.doc.ContainerDocBo.validate(ContainerDocBo.java:1299)| at com.frictionless.doc.AbsDocBo.validate(AbsDocBo.java:3138)| at com.frictionless.doc.BizDocBo.validate(BizDocBo.java:2110)| at com.frictionless.common.db.AbstractDb.validate(AbstractDb.java:6217)| at com.frictionless.common.db.AbstractDb.save(AbstractDb.java:3255)| at com.frictionless.doc.ContainerDb.save(ContainerDb.java:213)| at com.frictionless.doc.AbsDocDb.save(AbsDocDb.java:874)| at com.frictionless.common.db.AbstractDb.save(AbstractDb.java:3215)| at com.frictionless.doc.ContainerHome.save(ContainerHome.java:294)| at com.frictionless.doc.AbsDocHome.save(AbsDocHome.java:446)| at com.frictionless.contracts.ContractHome.save(ContractHome.java:131)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processApprovalActivity(PhaseChangeInstantiationRequestHandler.java:890)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processActivity(PhaseChangeInstantiationRequestHandler.java:300)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processHook(PhaseChangeInstantiationRequestHandler.java:249)| at com.frictionless.workflow.engine.handlers.WorkflowEngineRequestHandler.process(WorkflowEngineRequestHandler.java:197)| at com.frictionless.workflow.engine.WorkflowEngine.process(WorkflowEngine.java:412)| at com.frictionless.workflow.engine.WorkflowEngine.processPhaseChangeInstantiationRequest(WorkflowEngine.java:134)| at com.frictionless.workflow.engine.WorkflowEngineDaemon.processPhaseChangeInstantiationRequest(WorkflowEngineDaemon.java:328)| at com.frictionless.workflow.engine.WorkflowEngineDaemon.processHook(WorkflowEngineDaemon.java:148)| at com.frictionless.comp.daemon.AbsEventDaemon.process(AbsEventDaemon.java:151)| at com.frictionless.comp.daemon.ResponsibleEventDaemon.runHook(ResponsibleEventDaemon.java:143)| at com.frictionless.comp.daemon.ResponsibleDaemonBase.run(ResponsibleDaemonBase.java:301)| at java.lang.Thread.run(Thread.java:534)|AssociatedAttribute=COLLABORATOR_ROLE - SourceBo=-2147483075:508:Accounting Group - ValidatingParent=1258291201:1004:workflow - com.frictionless.api.common.exception.ApplicationException: Restricted To User is set to true on the Collaborator Role Object, so it can only be used with a user principal.| at com.frictionless.api.common.exception.ChainedExceptionFactory.createApplicationException(ChainedExceptionFactory.java:90)| at com.frictionless.common.db.PersistentBo.createApplicationException(PersistentBo.java:3160)| at com.frictionless.doc.collaboration.CollaboratorBo.validateHook(CollaboratorBo.java:1796)| at com.frictionless.doc.ContainerBo.validate(ContainerBo.java:1240)| at com.frictionless.doc.collection.SubCollnBo.validateCollection(SubCollnBo.java:1220)| at com.frictionless.doc.ContainerBo.execValidate(ContainerBo.java:3737)| at com.frictionless.doc.BizDocBo.execValidate(BizDocBo.java:1965)| at com.frictionless.doc.ContainerBo.validate(ContainerBo.java:1257)| at com.frictionless.doc.ContainerDocBo.validate(ContainerDocBo.java:1299)| at com.frictionless.doc.AbsDocBo.validate(AbsDocBo.java:3138)| at com.frictionless.doc.BizDocBo.validate(BizDocBo.java:2110)| at com.frictionless.common.db.AbstractDb.validate(AbstractDb.java:6217)| at com.frictionless.common.db.AbstractDb.save(AbstractDb.java:3255)| at com.frictionless.doc.ContainerDb.save(ContainerDb.java:213)| at com.frictionless.doc.AbsDocDb.save(AbsDocDb.java:874)| at com.frictionless.common.db.AbstractDb.save(AbstractDb.java:3215)| at com.frictionless.doc.ContainerHome.save(ContainerHome.java:294)| at com.frictionless.doc.AbsDocHome.save(AbsDocHome.java:446)| at com.frictionless.contracts.ContractHome.save(ContractHome.java:131)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processApprovalActivity(PhaseChangeInstantiationRequestHandler.java:890)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processActivity(PhaseChangeInstantiationRequestHandler.java:300)| at com.frictionless.workflow.engine.handlers.PhaseChangeInstantiationRequestHandler.processHook(PhaseChangeInstantiationRequestHandler.java:249)| at com.frictionless.workflow.engine.handlers.WorkflowEngineRequestHandler.process(WorkflowEngineRequestHandler.java:197)| at com.frictionless.workflow.engine.WorkflowEngine.process(WorkflowEngine.java:412)| at com.frictionless.workflow.engine.WorkflowEngine.processPhaseChangeInstantiationRequest(WorkflowEngine.java:134)| at com.frictionless.workflow.engine.WorkflowEngineDaemon.processPhaseChangeInstantiationRequest(WorkflowEngineDaemon.java:328)| at com.frictionless.workflow.engine.WorkflowEngineDaemon.processHook(WorkflowEngineDaemon.java:148)| at com.frictionless.comp.daemon.AbsEventDaemon.process(AbsEventDaemon.java:151)| at com.frictionless.comp.daemon.ResponsibleEventDaemon.runHook(ResponsibleEventDaemon.java:143)| at com.frictionless.comp.daemon.ResponsibleDaemonBase.run(ResponsibleDaemonBase.java:301)| at java.lang.Thread.run(Thread.java:534)	Unexpected error handling event
2011-09-30 00:11:06.192	DEBUG	local4	LogInfoBo	setStacktrace	Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)					truncated stacktrace because it was > 1000 chars
2011-09-30 00:11:06.239	DEBUG	local4	ResponsibleEventDaemon	repostEvent()	Daemon-028: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon			Event Reposted Owner=-520093695:1937:null, Source=-2147483537:2002:wf1, Subtype=1, Multicast Id=*

Waiting for the replies..

Former Member
0 Kudos

Hi,

That was a good progress & you are on your way to see it working soon

In your prescript, guess you are trying to add a user group as an approver. the excepion indicates for "approver" collaborator role defined in the system allows only user are collaborator and not user groups.

To fix this enable approver role to allow user groups. To do this go to setup>document setup>collaborator role defnitions. Look for approver role and uncheck the checkbox "restricted to users" checkbox.

Once this is done you should see the approval request..

Thanks, baski

Former Member
0 Kudos

Hello Experts,

Now the workflow is getting executed and can see the log messages.But the users in the group are not getting mails for approval and they are not able to approve/reject the contract document .

Is there any security roles missing ?, would appreciate your help to resolve the issue

Thanks and regards,

Kubra

Former Member
0 Kudos

Hello experts,

I have changed my code as given below


import com.frictionless.api.common.log.*;
import com.frictionless.api.doc.collaboration.*;
import com.frictionless.api.common.types.*; 
import com.frictionless.api.ibean.*;
import com.frictionless.api.doccommon.doc.contract.*;
import com.frictionless.api.usermgmt.masterdata.*;
import com.frictionless.api.contracts.*;

log = Logger.createLogMessage(session);
log.setLogMessage("Start Of Workflow");
Logger.info(log);

GroupIBeanHomeIfc home = (GroupIBeanHomeIfc) IBeanHomeLocator.lookup(session, GroupIBeanHomeIfc.sHOME_NAME);
//Find the group
sam_grp= home.findGroup("grp_accounting");
//Add the Approver 
addApprover(sam_grp.getObjectReference(), new CollaboratorApprovalRuleType(0));

but still it is not working,Please check the code and kindly let me know if I need to change anything

In my xpdl file there is one activity with the precript as given above.

Thanks and regards,

Kubra.

Former Member
0 Kudos

Hi Kubra,

Its gr8 to see , you are working with workflow tool.

I am new to E-Sourcing, can you please provide the steps how to create workflow and deploying steps.

Like I need the following steps

1. From where you are Initiating the workflow from E-Sourcing

2. After creating the workflow, are you exporting the xpdl or any .WAR specific things

3.Make them build and deploy the xpdls / java codes.

4. Where java code is coming in to the picture

5. Where we can place the beanshell scripts in the server, or you placing in jar file?

Please provide us you known steps to create first workflow in e-sourcing. And I am trying to create from TWF editor to create the workflows.

thanks

Srini

Former Member
0 Kudos

Thank you experts,

It would be very much grateful, if complete precript code starting from importing the correct packages is provided.

I am strugging a lot with the following code



import com.frictionless.api.doc.collaboration.*;
import com.frictionless.api.ibean.*;
import com.frictionless.api.doccommon.masterdata.*;
import com.frictionless.api.doccommon.doc.contract.*;
import com.frictionless.api.common.types.TypeFactory.*; 
import com.frictionless.api.usermgmt.masterdata.*;


log = Logger.createLogMessage(session);
log.setLogMessage("Start Of Workflow");
Logger.info(log);
if(hasValue(doc.getParentIBean())){ 
parentContainer = doc.getParentIBean(); 
// Get collaborators associated with the Agreement and attach an iterator to it
collab = parentContainer.getCollaborators();
Iterator iter = collab.iterator();

//Iterate over the collaborators to retrieve the Approver
while(iter.hasNext()){
log.setLogMessage("Inside while");
Logger.info(log);
member = iter.next();
//Check role of each collaborator, retrieve user with role "Approver"
role = member.getCollaboratorRole().toString();
log.setLogMessage(role);
Logger.info(log);
if(role.equals("Approver")){
//add user as Approver
principal = member.getObjectReference();
addApprover(principal);
}
}
}
else { 
// Handle parent-not-loaded condtn here 
cancelProcess("Parent Document not loaded. Contact a System Administrator."); 
return; 
}

I am getting the below error



com.frictionless.api.common.exception.ApplicationException: This field is required and must have a value.Stack Trace: AssociatedAttribute=WORK_ITEMS - SourceBo=-2147483547:1907:Hierarchical Approval Process - ValidatingParent=-2147483547:1907:Hierarchical Approval Process - com.frictionless.api.common.exception.ApplicationException: At least one of the items above is invalid. Mouse over the highlighted area for more details.
at com.frictionless.api.common.exception.ChainedExceptionFactory.createApplicationException(ChainedExceptionFactory.java:90)
at com.frictionless.common.db.PersistentBo.createApplicationException(PersistentBo.java:3160)
at com.frictionless.doc.collection.GeneralCollnBo.createApplicationException(GeneralCollnBo.java:324)
at com.frictionless.doc.collection.GeneralCollnBo.createApplicationException(GeneralCollnBo.java:336)
at com.frictionless.doc.collection.AssocCollnBo.validateCollection(AssocCollnBo.java:998)

Please let me know from where I can get the fciiapi.jar

Thanks,

Kubra.

ritikbaral
Explorer
0 Kudos

Hi Kubra,

Please find the below code to add approver in workflow for contract document.

GroupIBeanHomeIfc home = (GroupIBeanHomeIfc) IBeanHomeLocator.lookup(session, GroupIBeanHomeIfc.sHOME_NAME);
//Find the group
sam_grp= home.findGroup("Pass Your Group Name");
//Add the Approver 
addApprover(sam_grp.getObjectReference(), new CollaboratorApprovalRuleType(0));

Please let me know , whether the above code is helpful or not & Please do not forget to import the APIs.

Thanks,

Ritik Baral

Former Member
0 Kudos

Hi,

here is an example/psueo code..

e.g.

//get the user object reference use home locator

String userid = "johnappleseed";

principal = createObjectReferenceFromExternalID("STANDARD_ATTRIBUTE_ID", userid, 104)

//add the prinipal as approver to the document

addApprover(ObjectReferenceIfc principal)

Thanks, Baski