table yang akan kita gunakan adalah : EcoResProduct
1. Buat sebuah enum dengan lima opsi/element.
contoh Productreleaseapprovalstate.
Productreleaseapprovalstate.Draft
Productreleaseapprovalstate.Inreview
Productreleaseapprovalstate.Canceled
Productreleaseapprovalstate.Rejected
Productreleaseapprovalstate.Approved
2. Tambahkan enum tadi di table EcoResProduct
3. ditable EcoResProduct tambahkan method canSubmittoWorkflow
public boolean canSubmitToWorkflow(str _workflowType = '')
{
boolean ret = false;
if(this.RecId && this.PSMReleaseproductstate == PSMReleaseproductstate::Draft)
ret = true;
//ret = super(_workflowType);
return ret;
}
4. ditable EcoResProduct tambahkan method updateWorkflowState
static void updateWorkflowState(RefRecId _Id, PSMReleaseproductstate _state)
{
EcoResProduct ecoresproduct;
;
ecoresproduct = EcoResProduct::find(_Id, true);
ttsBegin;
ecoresproduct.PSMReleaseproductstate = _state;
ecoresproduct.update();
ttsCommit;
}
5. Buat Query
6. Buat Workflow category
Expand workflow category > Klik kanan > pilih New Workflow category.
Properties :
Properties :
key in nama category, label, help text, pilih modulenya.
7. Buat menu item display untuk formnya. jika sudah ada maka tidak usah.
8. Buat Workflow type
Expand Workflow
Pilih Workflow type > klik kanan > Add ins > Workflow type wizard.
Nama : isi dengan nama Workflowtype
Query : isi dengan query yang tadi dibuat
Document menu item : isi dengan menu item diplay dari formnya.
Workflow category : isi dengan WF Category yang tadi dibuat.
9. Edit Properties Workflow type.
Label
Help text
10. Edit properties menuitem Cancel dan Submit.
Label
Help text
11. Edit Properties form,
Workflow enable = Yes
Workflow datasource = [nama table]
Workflow type = [isi dengan worklfow type yang tadi dibuat]
12. Expand class Submit Manager, buka Class declaration. tambahkan variable dibawah ini dan nama Table yang dipakai.
InventTable inventTable;
WorkflowVersionTable workflowConfigurationTable;
WorkflowComment workflowComment;
boolean submit;
WorkflowWorkItemTable workflowWorkItemTable;
UserId userId;
MenuItemName menuItemName;
EPWorkflowControlContext workflowControlContext;
WorkflowTypeName workflowTemplateName;
13. Buat method parmData
public InventTable parmData(InventTable _currData = currData)
{
;
currData = _currData;
return currData;
}
14. Buat method parmMenuItem
public MenuItemName parmMenuItemName(MenuItemName _menuItemName = menuItemName)
{
;
menuItemName = _menuItemName;
return menuItemName;
}
15. Buat method parmSubmit
public boolean parmSubmit(boolean _submit = submit)
{
;
submit = _submit;
return submit;
}
16. Buat method parmWorkflowComment
public WorkflowComment parmWorkflowComment(WorkflowComment _workflowComment = workflowComment)
{
;
workflowComment = _workflowComment;
return workflowComment;
}
17 Buat method parmWorkflowConfigurationTable
public WorkflowVersionTable parmWorkflowConfigurationTable(WorkflowVersionTable _workflowConfigurationTable = workflowConfigurationTable)
{
;
workflowConfigurationTable = _workflowConfigurationTable;
return workflowConfigurationTable;
}
18. Buat method parmWorkflowControlContext
public EPWorkflowControlContext parmWorkflowControlContext(EPWorkflowControlContext _workflowControlContext = workflowControlContext)
{
;
workflowControlContext = _workflowControlContext;
return workflowControlContext;
}
19. Buat method parmWorkflowTemplateName
public WorkflowTypeName parmWorkflowTemplateName(WorkflowTypeName _workflowTemplateName = workflowTemplateName)
{
;
workflowTemplateName = _workflowTemplateName;
return workflowTemplateName;
}
20. Buat method parmWorkflowWorkItemtable
public WorkflowWorkItemTable parmWorkflowWorkItemtable(WorkflowWorkItemTable _workflowWorkItemTable = workflowWorkItemTable)
{
;
workflowWorkItemTable = _workflowWorkItemTable;
return workflowWorkItemTable;
}
21. Buat method
void reSubmit(Args _args, RecId _recId)
{
InventTable localData;
NoYes reSubmittingFromWeb;
;
update_recordset localData setting IsWorkflowToBeResubmitted = true
where localData.RecId == _recId;
Workflow::cancelWorkflow(this.parmWorkflowWorkItemtable().CorrelationId, this.parmWorkflowComment());
}
22. Buat method
public void submit()
{
NoYes activatingFromWeb;
InventTable inventtable;
// If we have a workflow control context, we are being activated from EP
activatingFromWeb = this.parmWorkflowControlContext() == null ? NoYes::No : NoYes::Yes;
ttsbegin;
InventTable::updateWorkflowState(currData.RecId, PSMRealaseProductWF::Inreview);
Workflow::activateFromWorkflowType(this.parmWorkflowTemplateName(),
currData.RecId,
this.parmWorkflowComment(),
activatingFromWeb,
DirPersonUser::worker2UserId(currData.Preparer));
ttscommit;
}
23. Buat MEthod
public static void main(Args args)
{
InventTable localData;
PSMReleasProducttypeSubmitManager submitManager;
boolean ret = true;
Object callerDataSource;
;
localData = args.record();
submitManager = new PSMReleasProducttypeSubmitManager();
submitManager.parmData(localData);
if (args.menuItemName() == menuitemActionStr(PSMReleasProducttypeSubmitMenuItem) ||
args.menuItemName() == menuitemActionStr(PSMReleasProductApprResubmitMenuItem))
{
submitManager.init(args.record(), args.menuItemName(), args.caller().getActiveWorkflowConfiguration(), args.caller().getActiveWorkflowWorkItem(), null);
}
else
{
submitManager.init(args.record(), args.menuItemName(), null, null, args.caller());
}
if (ret && submitManager.dialogOk())
{
if (args.menuItemName() == menuitemActionStr(PSMReleasProducttypeSubmitMenuItem))
{
submitManager.submit();
}
else
{
submitManager.reSubmit(args, localData.RecId);
}
}
if (!webSession())
{
callerDataSource = args.record().dataSource();
if (callerDataSource)
{
callerDataSource.research(true);
}
args.caller().updateWorkflowControls();
}
}
24. Buat method
public boolean dialogOk()
{
WorkflowSubmitDialog workflowSubmitDialog;
WorkflowWorkItemActionDialog workflowWorkItemActionDialog;
boolean ok;
;
if (menuItemName == menuitemActionStr(PSMReleasProducttypeSubmitMenuItem))
{
workflowSubmitDialog = WorkflowSubmitDialog::construct(this.parmWorkflowConfigurationTable());
workflowSubmitDialog.run();
this.parmWorkflowComment(workflowSubmitDialog.parmWorkflowComment());
ok = workflowSubmitDialog.parmIsClosedOK();
}
else if (menuItemName == menuitemActionStr(PSMReleasProductApprResubmitMenuItem))
{
workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct( workflowWorkItemTable,
WorkflowWorkItemActionType::Resubmit,
new MenuFunction(menuitemActionStr(PSMReleasProductApprResubmitMenuItem), MenuItemType::Action));
workflowWorkItemActionDialog.run();
this.parmWorkflowComment(workflowWorkItemActionDialog.parmWorkflowComment());
ok = workflowWorkItemActionDialog.parmIsClosedOK();
userId = workflowWorkItemActionDialog.parmTargetUser();
}
return ok;
}
25. Buat method
public void init( Common _documentRecord,
MenuItemName _menuItemName,
WorkflowVersionTable _workflowConfigurationTable,
WorkflowWorkItemTable _workflowWorkItemTable,
EPWorkflowControlContext _workflowControlContext
)
{
//if (_documentRecord.TableId == tableNum(RsPcmSPLTable))
//{
// this.parmData(_documentRecord);
//}
this.parmSubmit(_menuItemName == menuitemActionStr(PSMReleasProducttypeSubmitMenuItem));
this.parmMenuItemName(_menuItemName);
if (_workflowControlContext)
{
this.parmWorkflowControlContext(_workflowControlContext);
this.parmWorkflowWorkItemtable(_workflowControlContext.getActiveWorkflowWorkItem());
this.parmWorkflowComment(_workflowControlContext.getWorkflowComment());
this.parmWorkflowTemplateName(_workflowControlContext.getActiveWorkflowConfiguration().workflowTable().TemplateName);
}
else
{
this.parmWorkflowConfigurationTable(_workflowConfigurationTable);
this.parmWorkflowWorkItemtable(_workflowWorkItemTable);
this.parmWorkflowTemplateName(this.parmWorkflowConfigurationTable().workflowTable().TemplateName);
}
}
Tidak ada komentar:
Posting Komentar