hljs.configure({cssSelector: "code"}); hljs.highlightAll();

Thursday, May 25, 2023

X++ Code to change form link type for datasource in D365FO

 Here we are taking the post event handler of init method of standard class. by using the below code we can change the link type for a datasource.
 
    [PostHandlerFor(classStr(RuntimeFormExtensionApplier), staticMethodStr(RuntimeFormExtensionApplier, OnFormInit))]
    public static void RuntimeFormExtensionApplier_Post_OnFormInit(XppPrePostArgs _args)
    {
        #ISOCountryRegionCodes
        const str dataSourceCustTable = 'TaxInformationCustTable_IN';
        Form frm = _args.getArg('_form') as Form
        if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]) && formStr(CustTable) == frm.name())
        {
            FormBuildDataSource fbds = frm.dataSource(dataSourceCustTable);
            if (fbds != null)
            {
                fbds.linkType(FormLinkType::InnerJoin);
            }
        }
    }


Keep learning!!

No comments:

Post a Comment