Submit
Tue Dec 31 2024 10:29:44 GMT+0000 (Coordinated Universal Time)
Saved by @MinaTimo
/// <summary>
/// The NW_FirstDayOrientationWFTypeSubmitManager menu item action event handler.
/// </summary>
public class NW_FirstDayOrientationWFTypeSubmitManager
{
public static void main(Args args)
{
// Variable declaration.
recId recId;
WorkflowCorrelationId workflowCorrelationId;
// Hardcoded workflow type name
workflowTypeName workflowTypeName = workflowtypestr("WFType Name");
// Initial note is the information that users enter when they
// submit the document for workflow.
WorkflowComment initialNote = "";
WorkflowSubmitDialog workflowSubmitDialog;
// The name of the table containing the records for workflow.
NW_FirstDayOrientation Request;
FormDataSource Request_ds;
////
//// add validation here
////
str menuItemName = args.menuItemName();
if(menuItemName == menuitemactionstr(NW_FirstDayOrientationWFTypeSubmitMenuItem))
{
// Workflow is starting from the Windows client. This can be determined
// because the menu item for submitting the workflow on the Windows
// client was chosen by the user.
// Opens the submit to workflow dialog.
workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();
if (workflowSubmitDialog.parmIsClosedOK())
{
// Find what record from the Work Orders table is being submitted to workflow.
recId = args.record().RecId;
// Get comments from the submit to workflow dialog.
initialNote = workflowSubmitDialog.parmWorkflowComment();
try
{
// Update the record in the AbsenceRequestHeader table that is being submitted to workflow.
// The record is moved to the 'submitted' state.
Request = args.record();
Request.WorkflowState = TradeWorkflowState::Submitted;
// Activate the workflow.
workflowCorrelationId = Workflow::activateFromWorkflowType(workflowTypeName, recId, initialNote, NoYes::No);
// Update the table using the form datasource.
Request_ds = Request.dataSource();
if (Request_ds)
{
Request_ds.write();
Request_ds.refresh();
}
// Updates the workflow button to diplay Actions instead of Submit.
args.caller().updateWorkflowControls();
}
catch(exception::Error)
{
info("Error on workflow activation.");
}
}
}
else //// if the user press save and submit button the below work
{
recId = args.record().RecId;
try
{
// Update the record in the AbsenceRequestHeader table that is being submitted to workflow.
// The record is moved to the 'submitted' state.
Request = args.record();
Request.WorkflowState = TradeWorkflowState::Submitted;
// Activate the workflow.
workflowCorrelationId = Workflow::activateFromWorkflowType(workflowTypeName, recId, initialNote, NoYes::No);
// Update the table using the form datasource.
Request_ds = Request.dataSource();
if (Request_ds)
{
Request_ds.write();
Request_ds.refresh();
}
}
catch(exception::Error)
{
info("Error on workflow activation.");
}
}
}
}



Comments