Sample runbase with parameters

 class BPAADTerminationTriggerService   extends RunBaseBatch

{

    TransDate terminationDate;

    DialogField fieldTerminationDate;

   

    public server static BPAADTerminationTriggerService construct()

        {

            return new BPAADTerminationTriggerService();

        }


    public void initParmDefault()

    {

        super();

        terminationDate = systemDateGet();

    }


    public Object dialog()

    {

        DialogRunbase dlg;

        ;

 

        dlg                 = super();


        fieldTerminationDate        = dlg.addFieldValue(extendedTypeStr(TransDate), terminationDate, "Terminate selected workers upto", "it triggers azure AD termination process depending on selection date");

 

        return dlg;

    }


        /// <summary>

        /// </summary>

        /// <returns>Return the class desc</returns>

        public client server static ClassDescription description()

        {

            return "Azure AD user termination  process";

        }


        /// <summary>

        /// </summary>

        /// <returns>Whether the class can be used in a batch task</returns>

        protected boolean canGoBatchJournal()

        {

            return true;

        }


        /// Allows the class go batch

        /// </summary>

        /// <returns>Return the result</returns>

        public boolean canGoBatch()

        {

            return true;

        }


        /// <summary>

        /// </summary>

        /// <returns>Return the true result</returns>

        public boolean runsImpersonated()

        {

            return true;

        }


public boolean getFromDialog()

    {

        boolean ret;

    

        ret = super();


        terminationDate    = fieldTerminationDate.value();

    

        return ret;

    }


        public static void main(Args _args)

        {

            BPAADTerminationTriggerService    triggerService = BPAADTerminationTriggerService::construct();

     

            if (triggerService.prompt())

            {

                triggerService.run();

            }

        }


        public void run()

        {

            BPAADHCMWorkerLog     workerLog;

            HcmEmployment             employment;

         

        utcdatetime terminationDateTime = DateTimeUtil::newDateTime(terminationDate,86400);


            BPAADEmpImportInegraitonParameters intParam = BPAADEmpImportInegraitonParameters::find();


            if(intParam.EnableFunctionality && terminationDate)

            {

                ttsbegin;

                update_recordset workerLog

                    Setting  BPAADExecutionSummaryStatus = BPAADExecutionSummaryStatus::Executing

                     where workerLog.BPAADExecutionSummaryStatus == BPAADExecutionSummaryStatus::NotRun

                    &&     workerLog.BPMPAADInsertUpdateDelete == BPMPAADInsertUpdateDelete::Delete

                    &&   workerLog.CustomUserId

                    exists join employment

                    where employment.Worker == workerLog.worker 

                    &&    employment.ValidTo <= terminationDateTime;

                ttscommit;


                while select  workerLog

                    where workerLog.BPAADExecutionSummaryStatus == BPAADExecutionSummaryStatus::Executing

                    &&     workerLog.BPMPAADInsertUpdateDelete == BPMPAADInsertUpdateDelete::Delete

                    &&   workerLog.CustomUserId

                   

                    exists join employment

                    where employment.Worker == workerLog.worker

                    &&    employment.ValidTo <= terminationDateTime

                {


                    BPAADImportUserNameDeleteBusinessEvent businessEvent = BPAADImportUserNameDeleteBusinessEvent::newFromHCMWorker(HcmWorker::find(workerLog.Worker));

                    if(businessEvent)

                    {

                        businessEvent.send();

                    } 

                }

            }

        }


}

Comments

Popular posts from this blog

Ledger dimensions and financial Dimensions X++

Logistics address, postal address, address phone fax contact information

Consume odata/web api d365fo and parsing json content