Lookup method with filter

 Class NGHcmWorkerTransferFrm_ReasonCodeCtrlEventhandler

{


   
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(HcmWorkerTransfer, NewReasonCode), FormControlEventType::Lookup)]
    public static void NewReasonCode_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(HcmReasonCode), sender);
        Query                   query;
        QueryBuildDataSource    qbds;
        QueryBuildRange         qbrTerminate,qbrResignation;
        FormReferenceGroupControl actionState = sender.formRun().design(0).controlName(formControlStr(HcmWorkerTransfer,HcmActionState_ActionTypeSetup));
        
        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;


       sysTableLookup.addLookupfield(fieldNum(HcmReasonCode, ReasonCodeId));
        sysTableLookup.addLookupfield(fieldNum(HcmReasonCode, Description));
        
        query       = new Query();
        qbds        = query.addDataSource(tableNum(HcmReasonCode));
        
        qbrTerminate    = qbds.addRange(fieldNum(HcmReasonCode, IsTerminationApplicable));
        qbrResignation  = qbds.addRange(fieldNum(HcmReasonCode, IsResignationApplicable));
        if(HcmActionTypeSetup::find(actionState.value()).ActionType == HcmActionType::NGEmployeeFFDemise)
        {
            qbrTerminate.value(queryValue(NoYes::Yes));
        }
        
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
       
        if(ce)
        {
            ce.CancelSuperCall();
        }


   }

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++