web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Attach Display method in Table field group of InventDim table D365 F&O

(0) ShareShare
ReportReport
Posted on by 758

Hi Everyone,

I have created one extension class of InventDim table and have written display method into it. CoC looks like below,

[ExtensionOf(tableStr(InventDim))]
final class SIInventDim_Extension
{

    /// 
    /// to get the color code related to invent color.
    /// 
    /// 
    /// Color code from EcoResColor.
    /// 
    /// 
    /// 
    /// 
    
    display CHI_ColorCode disCHI_EcoResColor_ColorCode()
    {
        return EcoResColor::findByName(this.InventColorId).CHI_ColorCode;
    }

}

But whenever I attach the same in Field group of InventDim Table as shown below and as InventDim table has reference in BOMTable form as well.

I tried opening Bill of Materials page from dashboard I get below error,

"Menu item could not be opened. Object reference not set to an instance of an object."

However, attaching table method in field group works perfectly for other tables. Does InventDim table have some limitations in D365?

I wanted to display one customized field in Field group inventory dimesions. So that where ever this group has been called, my field will get reflected.

CHI.png

Thank you in advance.

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhushikesh,

    The display method should a static method and the table buffer should be passed into it. Please check here for an example.

    Your method should look like this -

    public static display CHI_ColorCode disCHI_EcoResColor_ColorCode(InvcentDim _inventDim)
    {
        return EcoResColor::findByName(_inventDim.InventColorId).CHI_ColorCode;
    }

    Also, it should be referenced as SIInventDim_Extension::disCHI_EcoResColor_ColorCode in the form control.

  • Rhushikesh R Profile Picture
    758 on at

    Hi Gunjan,

    I have made the method static and passed table buffer as well. But still facing same error.

    I am trying to attach the method to Field of Field Group at table level.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhushikesh,

    You mentioned that it is working fine for other tables. In case of the other tables, did you create the display method in the same way?

  • Rhushikesh R Profile Picture
    758 on at

    Hi Gunjan, I just checked. Actually error is being thrown from InventDimMetaDataCache class' getFieldGroupFieldsFromMetaData method.

    To overcome this issue in Ax2012, we had some customization like below,

    /// 
    ///    Retrieves the list of field IDs from a field group of a table.
    /// 
    /// 
    ///    The ID of a table for which to get the fields.
    /// 
    /// 
    ///    The name of a field group in the table that is specified by the 
    ///    parameter for which fields are to be returned.
    /// 
    /// 
    ///    If this parameter is true, the configuration key for the field will be checked.
    /// 
    /// 
    ///    A container that has field names or IDs.
    /// 
    static protected List getFieldGroupFields(
        TableId         _tableId,
        str             _fieldGroupStr,
        boolean         _cfgEnabled)
    {
        DictTable               dt = new DictTable(_tableId);
        DictFieldGroup          dfg;
        DictField               df;
        DictConfigurationKey    dck;
        int                     i, h;
        List                    result = new List(Types::Integer);
    
        for (i = 1; i <= dt.fieldGroupCnt(); i  )
        {
            if (dt.fieldGroup(i) == _fieldGroupStr)
            {
                dfg = new DictFieldGroup(_tableId,dt.fieldGroup(i));
                for (h = 1; h <= dfg.numberOfFields(); h  )
                {
                    df  = new DictField(_tableId,dfg.field(h));
                    
                    // Customized code 
                    if(df == null)
                    {
                        continue;
                    }
                    // Customized code 
                    
                    
                    dck = new DictConfigurationKey(df.configurationKeyId());
                    if (!_cfgEnabled || !df.configurationKeyId() || dck.enabled())
                    {
                        result.addEnd(df.id());
                    }
                }
            }
        }
    
        return result;
    }

    How can I map same customization in D365?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhushikesh,

    Can you check where this method is being called from? We might need to write a new method and replicate the functionality.

    Also, could you please tell me the exact requirement here?

  • Rhushikesh R Profile Picture
    758 on at

    The method is being called from getFieldGroupFields method of same class.

    And we have requirement as below,

    I need to display customized Color code inventory dimension just below Color inventory dimension.

    So wherever this field group has been called. It will get reflected in same field group.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhushikesh,

    Please try this and check if this will help.

    1. Do a CoC on "getFieldGroupFields" method. 

    2. Write your custom method as a static method (as per the customizations done in AX 2012).

    3. In the CoC, call the static method insert the fieldList into the cache using -

    sysGlobalObjectCache.insert(CacheClassScope, cacheKey, fieldList.pack());

    4. The next call for the CoC should be after this logic. This way, when the original logic checks for packedFields in the cache, it will find the record and not execute the logic for "getFieldGroupFieldsFromMetaData" method.

    Hope this made sense.

  • Suggested answer
    Rhushikesh R Profile Picture
    758 on at

    Yes Gunjan, it seems to be valid one.

    Could you please quickly review below CoC which I have just written. I just tried to handle exception. Could this be valid solution as well?

    The form opens without any error using below CoC.

    [ExtensionOf(classStr(InventDimMetaDataCache))]
    final class SIInventDimMetaDataCache_Extension
    {
        static protected List getFieldGroupFields(
            TableId         _tableId,
            str             _fieldGroupStr,
            boolean         _cfgEnabled)
        {
            List          fieldList;
    
            try
    		{
    			fieldList = next getFieldGroupFields(_tableId,_fieldGroupStr,_cfgEnabled);
            }
            catch(Exception::CLRError)
            {
                info("Exception occurred");
    
                fieldList = InventDimMetaDataCache::getSIFieldGroupFieldsFromMetaData(_tableId,_fieldGroupStr,_cfgEnabled);
            }
    
            return fieldList;
        }
    
        static private List getSIFieldGroupFieldsFromMetaData(
            TableId         _tableId,
            str             _fieldGroupStr,
            boolean         _cfgEnabled)
        {
            List result = new List(Types::Integer);
            DictFieldGroup dictFieldGroup = new DictFieldGroup(_tableId, _fieldGroupStr);
            if (dictFieldGroup)
            {
                int fieldCnt = dictFieldGroup.numberOfFields();
                for (int i = 1; i <= fieldCnt; i  )
                {
                    DictField dictField = new DictField(_tableId, dictFieldGroup.field(i));
                    if(dictField == null)
                    {
                        continue;
                    }
                    DictConfigurationKey dictConfigurationKey;
                    if (_cfgEnabled && dictField.configurationKeyId())
                    {
                        dictConfigurationKey = new DictConfigurationKey(dictField.configurationKeyId());
                    }
    
                    if (!dictConfigurationKey || dictConfigurationKey.enabled())
                    {
                        result.addEnd(dictField.id());
                    }
                }
            }
    
            return result;
        }
    
    }

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Rhushikesh,

    The issue might be that the exception will already be thrown in this case. You can give this a try and check if it works.

  • Rhushikesh R Profile Picture
    758 on at

    Hi Gunjan,

    Its working fine. But I just wanted to confirm the logic I have written. I am able to open form with above mentioned logic.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans