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);
}
}

Leave a comment