{
protected void new()
{
return;
}
{
RecID recID = _args.record().RecId;
TableId tableId = _args.record().TableId;
ProjProposalJour projProposalJour = _args.record();
WorkflowWorkItemTable workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowSubmitDialog workflowSubmitDialog;
WorkflowComment wfComment;
workflowTypeName workflowTemplateName = workFlowTypeStr('PSAProjInvoiceProposal');
if (tableId != tablenum(ProjProposalJour) ||
recId == 0)
{
throw error(strfmt("@SYS19306", funcname()));
}
{
// The journal does support workflow approvals.
workflowSubmitDialog = WorkflowSubmitDialog::construct(_args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();
if (WorkflowSubmitDialog.parmIsClosedOK())
{
wfComment=WorkflowSubmitDialog.parmWorkflowComment();
if (ProjProposalJour::findRecid(recID).LineProperty == ProjLinePropertyCode::Open)
{
// Validates and disallow workflow submission when project is in closed stage for invoice proposal.
PSAProjInvoiceProposalSubmitToWF::disallowSubmitIfProjStageIsClosed(projProposalJour.ProposalId);
Workflow::activateFromWorkflowType(workflowTemplateName, _args.record().RecId, wfComment, NoYes::No);
PSAProjInvoiceProposalStateChangeManager::updateProjInvoiceProposalStatus(_args.record().RecId,ProjLinePropertyCode::PSASubmitted);
}
}
}
PSAProjInvoiceProposalSubmitToWF::refreshCaller(_args);
}
{
FormRun callerForm;
FormDataSource projProposalJourDS;
{
if (SysDictClass::isEqualOrSuperclass(classidget(_args.caller()), classnum(FormRun)))
{
callerForm = _args.caller();
if (projProposalJourDS)
{
projProposalJourDS.reread();
projProposalJourDS.refresh();
projProposalJourDS.active();
callerForm.updateWorkflowControls();
}
}
}
}
/// Validates project stage to allow creation of invoice proposal before submit to workflow. An error will be thrown if project stage is not allowed for invoice proposal creation.
/// </summary>
/// <param name="_proposalId">
/// Reference to invoice proposal ID.
/// </param>
protected static void disallowSubmitIfProjStageIsClosed(ProjProposalId _proposalId)
{
ProjProposalTransUnion projProposalTransUnion;
ProjTable projTable;
from projTable
exists join projProposalTransUnion
where projProposalTransUnion.ProjId == projTable.ProjId
&& projProposalTransUnion.ProposalId == _proposalId
{
if (projTable && !ProjStatusTypeRule::exist(projTable.Status, projTable.Type, ProjStatusRule::CreateInvoiceProposal))
{
throw error(strFmt("@Proj:ProjClosedStageSubmitToWorkflowError", projTable.ProjId, projTable.Stage()));
}
}
}