1. create new document tables (has docaction,....)
2. setup workflow, add template code for it also
3. on prepare function do validate same MOrder, in case non document line then return error @NoLines@
1. create document header
2. complete it (done with error @NoLines@)
3. click complete button again, bellow error
compare to same condition when complete sale order.
when start MWFActivity for node "prepare" has 2 record of MWFActivity one for node "start" and on for node "prepare"
at time of process node "prepare" get error, it run to MWFProcess.checkActivities
after finish "for loop" of checkActivities value of "closedState" depend on order by of two MWFActivity
on Sale Order MWFActivity order by MWFActivity of "start" then MWFActivity of "prepare"
so "closedState" always not null
on new document it's difference. almost test run MWFActivity of "prepare" before MWFActivity of "start" and get error message "Active Workflow for this Record exists (complete first)"
a bit test run when MWFActivity of "start" before MWFActivity of "prepare" then no error happen
when "closedState" not null when code call to setWFState and it do "Force close to all Activities" so can run complete again without message "Active Workflow for this Record exists (complete first)"
MWFProcess.getActivities query MWFActivity without order by, so record return by order of updated time (it's not always but postgresql prefer this order by default)
review and modify code inside MWFProcess.checkActivities to don't depend on order of MWFActivity
add .setOrderBy(MWFActivity.COLUMNNAME_AD_WF_Activity_ID) to MWFProcess.getActivities
i will provide plugin of new document for test soon
Hi , I have not tested your scenario, but if adding an ORDER BY solves the issue I think is a simple and good way to do it.
i just done a project for reproduce this issue (but get issue with github to push, will push it later)
at moment i can't reproduce by new project also by my old project (what help me discover this issue)
but agree to after review code of MWFProcess.checkActivities then add sort by COLUMNNAME_AD_WF_Activity_ID is good to has at that point
by investigate (not success) why this issue not happen at moment i discover other thing (not sure it's bad or good)
by change of on MWFActivity.run (line 886-894 about localTrx and savePoint)
test case is same this issue, make a exception at prepare (complete a order without order line)
at time save terminate state of prepare activity it call to MWFProcess.checkActivities
at this time getActivities (true, true, trxName); return 2 record
1. record MWFActivity of start node with (State = ON, processed = N)
2. record MWFActivity of prepare node with (State = CT, processed = N)
before we get only record 2, because 1 already commit with state - CO, processed = Y