How to use document workflow from java API?

414 views
Skip to first unread message

Freddy Rodriguez

unread,
Apr 9, 2013, 11:52:47 AM4/9/13
to idem...@googlegroups.com
Hi Adempiere Community

Currently we have an approval (document) workflow to manage(review & approve) sale orders, so far it is  working well (nodes, transitions) when the order submission is performend from the Web UI,It intercepts the sales order during the stattus changes and send approval notifications (email) once the order is approved.
However, now we require to create/submit those sale orders from the java API (not from the webui), then we created a MOrder as a normal (standard order) and then we already tried to use the usual “order.completeIt()” method to complete the order (we have done this before without workflow logic), but in this case thought the workflow process should intercept that order(email and so on), it doesn´t work with the order created by our java process.

uestions:
 
1  Do we nee need something else (config or methods) so the workflow logic (nemail notification and approval transition)  works with our orders created from the java API  ?

2  Is that is true, is there any existent java class in the adempiere branch or example that uses that simple logic to start/use a document workflow process for a similar case (order workflow) where everything is already defined within the active dictionary (transitions, email notifications), and we just want to use it from the java code ?

Thanks,

Carlos Antonio Ruiz Gomez

unread,
Apr 9, 2013, 7:17:00 PM4/9/13
to idem...@googlegroups.com
Hi Freddy, in this case instead of completeIt you must run the process
corresponding to complete the order.

Regards,

Carlos Ruiz


On 09/04/13 10:52, Freddy Rodriguez wrote:
> Hi Adempiere Community
>
> Currently we have an approval (document) workflow to manage(review &
> approve) sale orders, so far it is working well (nodes, transitions)
> when the order submission is performend from the Web UI,It intercepts
> the sales order during the stattus changes and send approval
> notifications (email) once the order is approved.
> However, now we require to create/submit those sale orders from the
> java API (not from the webui), then we created a MOrder as a normal
> (standard order) and then we already tried to use the usual
> �order.completeIt()� method to complete the order (we have done this
> before without workflow logic), but in this case thought the workflow
> process should intercept that order(email and so on), it doesn�t work

Anozi Mada

unread,
Apr 9, 2013, 10:22:58 PM4/9/13
to idem...@googlegroups.com
Hi Freddy,

You can try this:

order.setDocAction(DocAction.ACTION_Complete);
order.processIt(DocAction.ACTION_Complete);

Freddy Rodriguez

unread,
Apr 10, 2013, 4:48:30 PM4/10/13
to idem...@googlegroups.com
Thank you for your answers.

I tried to do with the other processes:
order.setDocAction (DocAction.ACTION_Complete);
order.processIt (DocAction.ACTION_Complete);
OR
order.setDocAction (DocAction.STATUS_InProgress);
order.processIt (DocAction.ACTION_Complete);
OR
order.setDocAction (DocAction.STATUS_InProgress);
order.processIt (DocAction.ACTION_Prepare);

But I am afraid still does not work, any idea what else to try?

Freddy

Freddy Rodriguez

unread,
Apr 18, 2013, 6:56:14 PM4/18/13
to idem...@googlegroups.com
Hi Adempiere community.

Given that not yet run the workflow  with order.prepareit()  (order.processIt(DocAction.ACTION_Prepare) and another states), I've tried to execute the workflow as follows:
MWorkflow wf = MWorkflow.get(Env.getCtx(), 116);
MWFNode[] wfns = wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
MWFNode nod = wfns[i];
nod.getActionInfo();
nod.load(trx.getTrxName());


But this does not work, someone has done this and has some sample code I can use?

Thank a lot!


2013/4/10 Freddy Rodriguez <fre...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/I9wKnJLn0CA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to idempiere+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Freddy Rodriguez

unread,
Apr 19, 2013, 6:18:09 PM4/19/13
to idem...@googlegroups.com
HI.

I've done searching and I found an answer in a forum(http://red1.org/adempiere/viewtopic.php?f=34&t=1417) that said than for you can complete documents using workflow  you must use “DocumentEngine”, but I haven't found any documentation  or example of how you can use this class.
Someone has done this or has some sample code I can use or  have some documentation about DocumentEngine?

Thanks a lot!


2013/4/18 Freddy Rodriguez <fre...@gmail.com>

Heng Sin Low

unread,
Apr 19, 2013, 7:37:47 PM4/19/13
to idem...@googlegroups.com
you need to use ProcessUtil.startWorkFlow(Env.getCtx(), processinfo, ad_workflow_id)

to get ad_workflow_id:
ad_column ( c_order.docaction ).ad_process_id > ad_process.ad_workflow_id


You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.

Deepak Pansheriya

unread,
Apr 21, 2013, 1:03:31 PM4/21/13
to idem...@googlegroups.com
Freddy,

If you are trying to complete any of standard document like order, shipment etc. then you can use their model class to achieve this. For example you can look at MOrder.ProcessIt method which calls document engine to perform workflow action.

Hope this may answer your question.

Freddy Rodriguez

unread,
Apr 22, 2013, 10:31:10 AM4/22/13
to idem...@googlegroups.com
Heng Sin Low this  method respond my question 

Thanks everyone.


2013/4/21 Deepak Pansheriya <deepakpa...@gmail.com>

jaimegar...@gmail.com

unread,
Aug 31, 2015, 6:04:05 PM8/31/15
to iDempiere
Freddy;
can you explain me in more detail how to use ProcessUtil.startWorkFlow(Env.
getCtx(), processinfo, ad_workflow_id) I need it for complete an invoice
Regrads
J Garcia

Solutions Ocean.

unread,
Sep 1, 2015, 4:58:54 AM9/1/15
to idem...@googlegroups.com
Easy way is as follows.


MInvoice x = new MInvoice(Env.getCtx(), RECORD_ID, get_TrxName());
x.setDocAction (DocAction.ACTION_Complete);
x.processIt (DocAction.ACTION_Complete);

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/08c08349-1252-49f2-a079-2e96d9495f81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jaimegar...@gmail.com

unread,
Sep 1, 2015, 4:36:38 PM9/1/15
to iDempiere
Hi Kashif ,
Thanks for your help. I solved my problem with your advice.
I add other two lines and it works fine.
The lines I added
x.setProcessed(true);
x.saveEx();

Thanks again for your help
Reply all
Reply to author
Forward
0 new messages