Skip to main content

Lookup and Mandatory fields on Form using Form event Handlers D365


Lookup and Mandatory fields on Form using Form event Handlers D365

[FormControlEventHandler(formControlStr(VendBankAccounts, VendBankAccount_SLD_BankCode), FormControlEventType::Lookup)]

public static void VendBankAccount_SLD_BankCode_OnLookup(FormControl sender, FormControlEventArgs e)

    {

        Query query = new Query();

        QueryBuildDataSource queryBuildDataSource;

        FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;

        QueryBuildRange queryBuildRange;

        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SLD_BankCodes), sender);

        sysTableLookup.addSelectionField(fieldNum(SLD_BankCodes, BankCodes));

        sysTableLookup.addLookupField(fieldNum(SLD_BankCodes, BankCodes));

        sysTableLookup.addLookupField(fieldNum(SLD_BankCodes, Description));

        queryBuildDataSource = query.addDataSource(tableNum(SLD_BankCodes));

        sysTableLookup.parmQuery(query);

        sysTableLookup.performFormLookup();

        event.CancelSuperCall();

    }


    [FormEventHandler(formStr(VendBankAccounts), FormEventType::Activated)]

    public static void VendBankAccounts_OnActivated(xFormRun sender, FormEventArgs e)

    {

        FormDataSource VendBankAccounts_DS = sender.dataSource(tableStr(VendBankAccount));

        VendBankAccounts_DS.object(fieldNum(VendBankAccount, BankIBAN)).mandatory(true);

        VendBankAccounts_DS.object(fieldNum(VendBankAccount, SLD_BankCode)).mandatory(true);

    }

Comments

Popular posts from this blog

Edit Method on Form

Edit Method D365 for a form Data Source 1. To create an edit method first create a controller class. with following properties  public static edit MainAccountNum LedgerJournalTransLedger(LedgerJournalTrans _ledgerjournal, boolean _set, MainAccountNum _id) { MainAccountNum accountId = _id; MainAccount mainAccount = MainAccount::findByMainAccountId(_id); if(_set) { if(_ledgerjournal.AccountType== LedgerJournalACType::Ledger) { mainAccount = MainAccount::findByMainAccountId(accountId); if(_ledgerjournal.LedgerDimension) { DimensionDefault defaultDim = LedgerDimensionFacade::getDefaultDimensionFromLedgerDimension(_ledgerjournal.LedgerDimension); _ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId, DimensionHierarchy::getAccountStructure(mainAccount.RecId), defaultDim); } else { _ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId, DimensionHierarchy::ge...

Virtual Field

    VIRTUAL FIELD MAPPING IN AN ENTITY D365 FinOps 1. Create an unmapped field in an Entity Fields section and apply following properties to an unmapped field.  2. Same goes for Staging table : 3. Write following bunch of code in Entity code ( Press F7 ):  To check this field use import export in D365 or use excel add in to manipulate this unmapped field.     HEY HEY HEY !!!! HACK OF THE DAY !!!        entitytodatasource -------   write function        datasourcetoentity -------- read function

EXCEL Add-in D365 FO

EXCEL add-in USED FOR D365 DATA ENTITY To use excel add-in for D365 data entities for CRUD operations. You can easily follow below mentioned steps: 1. Open Excel from any Desktop or VM and click on Add-ins option under insert tab: 2. Check if you have Microsoft Dynamics Office Add-ins, If not then download it from Microsoft store: 3. If you have above mentioned Add-in click on this and click add server information: 4. In server URL add your environment URL either dev, UAT or PROD and click OK.  for e.g:  (https://xxxxxxxxxxxxxxxxxxx.dynamics.com/)  5. Click on Design button and it will display below mentioned screen: 6. Click on Select entity data source and choose your desired data entity from list on which you need to perform CRUD operations and click on NEXT: 7. Double click on each field present in AVAILABLE FIELD SECTION to get them in SELECTED FIELD SECTION: 8. Click on Refresh Once and you will be able to see data in your entity in Excel: 9. After making changes to...