AX – D365FO – Ho w to add a default value in a field and hide it in a Form grid

Result to obtain

go to “Vendor collaboration” –> “Vendor nformation” –>”Certifications”

A form will be opened “VendTableVendExternal”and a grid will appear

We want to set a default value for the field “Certifying organization” and hide it to the user.

How to do this in X++ :

Set Default value to the field

First create the default value into “Procurement and “sourcing parameters” form

Create the parameter that contains the default value

to do that create a table extension for the table “VendornformationFormConfiguration” and add the new filed “Al0IssuerPartyDefaultValue”

Syncronize database

Create the class “VendTableVendExternal_Handle”

class VendTableVendExternal_Handle
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(VendTableVendExternal, VendCertification), FormDataSourceEventType::Created)]
    public static void VendCertification_OnCreated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        //Al0_0270_VendorPortal - BEGIN
        //Default "vendCertification.IssuerParty" with parameter Al0IssuerPartyDefaulValue
        FormRun         form              = sender.formRun();
        FormDataSource  vendCertification_ds = form.dataSource(formDataSourceStr(VendTableVendExternal, VendCertification)) as FormDataSource;
        VendCertification vendCertification   = vendCertification_ds.cursor();
        
        vendCertification.IssuerParty  = VendorInformationFormConfiguration::find().Al0IssuerPartyDefaulValue;
        //Al0_0270_VendorPortal - END
    }

}

Hide field

Create an extension of the class “VendTableVendExternal”

[ExtensionOf(formStr(VendTableVendExternal))]
final class VendTableVendExternal_Extension
{
    public void init()
    {
        next init();

        VendCertification_ds.object(fieldNum(VendCertification, issuerParty)).visible(false);
    }

}

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...