The trouble is you think you have time. Your success depends on how you utilize your time.

Get Values of fields of Record from Form using FormDataSource EventHandler

How to create a form data source event handler and get the data of fields and also hide some fields.

First go to the form, here is how go to application explorer then type the name of the form then by open designer of that form using right click then go to the data source and find the event where you want to hide your fields.

www.Moznum.com   [FormDataSourceEventHandler(formDataSourceStr(InventJournalMovement, InventJournalTable), FormDataSourceEventType::Activated)]

I am using Activated event handler, for that just create a simple class and copy the event handler and paste it to the class.

Moznum.com OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

then using following code you can get the record,  and hide the field using visible property.

    [FormDataSourceEventHandler(formDataSourceStr(InventJournalMovement, InventJournalTable), FormDataSourceEventType::Activated)]
    public static void InventJournalTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        InventJournalTable inventJournalTable  = sender.cursor();
        InventJournalName InventJournalName ;
        select * from InventJournalName where InventJournalName.JournalNameId == inventJournalTable.JournalNameId;

        FormStringControl room = sender.formRun().design(0).controlName("InventJournalTrans_MZNUKRoom");
        FormStringControl building = sender.formRun().design(0).controlName("InventJournalTrans_MZNUKBuilding");
        FormStringControl Phase = sender.formRun().design(0).controlName("InventJournalTrans_MZNUKPhase");
        if (InventJournalName.MZNUKAllowExtraFields)
        {
            room.visible(true);
            building.visible(true);
            Phase.visible(true);
        }
        else 
        {
            room.visible(false);
            building.visible(false);
            Phase.visible(false);
        }
    }



Read how to make UIBuilder Class Click Here

Read how to make DP class for Contact Click Here

DP Class for UI Builder ListEnumerator d365 x++ Finance and Operations 

No comments:

Post a Comment