Friday, November 5, 2021

Get financial dimensions lookup in control using X++ in D365fo

 Get financial dimensions lookup in control using X++ in D365fo.

    public static void lookupControl(FormControl _formControl, str _value)

{ FormStringControl control; Args args; FormRun formRun; DimensionAttribute dimAttribute; dimAttribute = DimensionAttribute::findByName(_value); args = new Args(); args.record(dimAttribute); args.caller(_formControl); args.name(formStr(DimensionLookup)); formRun = classFactory.formRunClass(args); formRun.init(); control = _formControl as FormStringControl; control.performFormLookup(formRun); }

    -------------------------------------or---------------------------------------------------------------------------

    public void lookupLocation(FormStringControl _formControl) {

        QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; DimensionAttribute dimAttr; dimAttr = DimensionAttribute::findByName("Location"); Query query = new Query(); SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionAttributeValue),
                                                                                          _formControl); query.addDataSource(tablenum(DimensionAttributeValue)).addRange(fieldNum(DimensionAttributeValue,
                                                                           DimensionAttribute)).value(
                                                                              queryValue(dimAttr.RecId)); //query.addDataSource(tablenum(DimensionAttributeValue)).addRange(fieldNum(DimensionAttributeValue,
                                                                                 IsDeleted)).value(
                                                                                  sysquery::value(NoYes::No)); sysTableLookup.addLookupfield(fieldNum(DimensionAttributeValue, DisplayValue), true);
        // pass method
        //sysTableLookup.addLookupMethod(tableMethodStr(DimensionAttributeValue, methodname), true);
         //this code is to add the ranges for filtering sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup();

}

Keep Daxing!!

No comments:

Post a Comment