varication before take action WF

PHOTO EMBED

Wed Dec 11 2024 11:33:07 GMT+0000 (Coordinated Universal Time)

Saved by @MinaTimo

[ExtensionOf(classStr(WorkflowWorkItemActionManager))]
final class WorkflowWorkItemActionManagerHR_Extension
{
    public void run()
    {
        if(args.dataset() == tableNum(NW_PermGatePass))
        {
            NW_PermGatePass PermGatePass;
            select PermGatePass where PermGatePass.RecId==args.record().RecId;
            if(PermGatePass.WorkflowState == TradeWorkflowState::PendingApproval)
            {
                str currentStepName = NW_Helper::currentStep(PermGatePass.RecId, PermGatePass.TableId);

                if(HRMParameters::find().PublicRelationStep == currentStepName)
                {
                    NW_PermGatePass_PGP PGP;
                    select PGP where PGP.NWHR_PermGatePassRec == PermGatePass.RecId;
                    if(!PGP.PGP1 || !PGP.ForwardTo || !PGP.Palace || !PGP.PermitStartDate || !PGP.PermitEndDate)
                        throw error("Public Relation Fields must be fill in");
                }
                if(HRMParameters::find().AdministrativeCommunicationStep == currentStepName)
                {
                    if(!PermGatePass.ExportNbr || PermGatePass.Decision == NoYes::No || !PermGatePass.Note)
                        throw error("Administrative Communication Fields must be fill in");
                }
            }
        }
        next run();
    }

}
content_copyCOPY