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

Add user as the apporver in workflow

Former Member
0 Likes
791

Hi,

I have created workflow for Project. I would like to add a user as a approver by using the following code.

user = IapiAccountLocator.lookup(session,"noppong_test");
addApprover(user.getAccountObjectReference(), new CollaboratorApprovalRuleType(0));

When the document is moved to the phase the document is locked by workflow engine, but there is nothing happen. i also found the error in the log.

P.S. If you have an example to add the user as the approver. I'm appreciated if you provide me .

Daemon-027: EVENT_WORKFLOW_ENGINE (-2147483548, 0)	event_workflow_engine	daemon	com.frictionless.api.common.exception.ApplicationException: This field is required and must have a value.	AssociatedAttribute=WORK_ITEMS - SourceBo=-2144361477:1907:Contract Approval - ValidatingParent=-2144361477:1907:Contract Approval - 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)

Thank you so much,

noppong

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

Looks like you ran into some workflow engine error.. Look for any errors in the logs or in background task status. Check if you use the right version of the workflow editor.

Refer to my response in the threads. This may provide you additional pointers to debug this issue

http://forums.sdn.sap.com/thread.jspa?threadID=2028928

http://forums.sdn.sap.com/thread.jspa?threadID=2049322

Good luck

Baski

Former Member
0 Likes

Hi Baski,

Thank you so much for your response. It is so useful for me.

The issue has been resolved by uising the XPDL template from SAP. I have some question about changing the phase. I have 3 phases as the following :

1. Draft

2. Approval -> Workflow is here . Prev phase is Draft and Next Phase is Approved.

3. Approved

I added script to change phase in post script on the block activity as following

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

if(getApprovalStatus() != DENIED) { 
	doc.getIBeanHomeIfc().upgradeToEdit(doc); 
	doc.getIBeanHomeIfc().changePhase(doc,"Approved");
}else{
	doc.getIBeanHomeIfc().upgradeToEdit(doc); 
	doc.getIBeanHomeIfc().changePhase(doc,"Draft");
}

When the approver approve the document i found the error in backgroud task status as following:

-


Stack Trace: Sourced file: inline evaluation of: ``import com.sap.odp.api.common.*; if(getApprovalStatus() != DENIED) { doc.get . . . '' : target exception : at Line: 5 : in file: inline evaluation of: ``import com.sap.odp.api.common.*; if(getApprovalStatus() != DENIED) { doc.get . . . '' : .changePhase ( doc , "Approved" ) 

Target exception: com.frictionless.api.common.exception.ApplicationException: You may not transition to the target phase Approved. It is neither a valid next nor previous phase.

at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHIfStatement.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at com.frictionless.comp.scripting.ScriptEnviro...

-


It seem like the document is automatically changed the phase to 'Approved' and make the script error, and the document is locked on the Approved phase. I would like to ask you some more questions.

1. Why does the workflow change the phase automatically? On my understanding the phase should be handled in PostScript by the script

2. On my understanding the workflow engine will lock the document during the workflow. Why this workflow did not release the lock when the document was changed the phase to 'Approved'.

Thank you and appreciate your help

Noppong

Former Member
0 Likes

Hi,

Please find the response inline:

1. Why does the workflow change the phase automatically? On my understanding the phase should be handled in PostScript by the script

[ Baski: I don't think the phase transition has happened automatically. We heard in some instances postScript of the workflow is called more than once and that could be the cause of this issue. one recomenedation here is to make the script execution idempotent. e.g. check if the current phase is not "executed" before doing the transition to executed. (if (current_phase != Executed){ doc.changePhase("Executed")}

]

2. On my understanding the workflow engine will lock the document during the workflow. Why this workflow did not release the lock when the document was changed the phase to 'Approved'.

[Baski: as the postScript execution resulted in an error, the workflow engine still holds the lock I guess]

Please check

Good luck!

Baski

Former Member
0 Likes

Thanks you so much Baski. Your response is useful for me.

You are right. When i removed the PostScript the document did not change the phase that mean the PostScript excuted twice.

Thank you,

Noppong

Former Member
0 Likes

Hi,

It was mentioned that you have received the workflow template from SAP, i may need the sample XPLD template as well.

Thanks,

RR

Former Member
0 Likes

Hi RR,

Please leave your email, i will send you.

Thanks,

Noppong

Former Member
0 Likes

Thanks for the quick response.

Renga

rrengadurai at gmail.com

Former Member
0 Likes

Hi,

Thanks after using the template, still i am getting the error.

I have cleared the events error, log etc, but still getting the same error. Not sure if this is something to do with the workflow engine itself. Any inputs on this is greatly appreciated.

BTW.. the event is trigered successfully.

Thanks.

RR

Former Member
0 Likes

Hi Noppong

I am facing issues with workflow template as well. Can you plz mail me standard SAP workflow template? My E MailID is mentioned in my signature.

I shall be greatful

Regards

Shobha

Former Member
0 Likes

Hi Shobha,

i already sent it. please check.

Noppong

Former Member
0 Likes

Thanks a lot Noppong!

It has been really helpful.

Regards

Shobha

Former Member
0 Likes

Hi,

I understand this thread is answered but unfortunately i have tried each and every step but still same error.

any recommendation/suggestion?

Cheers,

Renga

Answers (0)