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

Billability and Resource Category auto mapping

(0) ShareShare
ReportReport
Posted on by 212

Hello

I have a form named "ResourceReqTableList" in which I have two fields named Billability and Resource Category. Billability has 3 line properties namely billable, BT and non billable while Resource category is an enum having multiple values. My requirement is that  While selecting billable option in Billability, only ‘Project Allocated’ should be reflected under Resource category and if we select non billable option in Billability field, then â€˜Project Allocated’ option should not be reflected under the Resource category field.

Please help me achieve this.

Thanks and Regards

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, If I understood your question correctly, you want to display certain enum values based on selection of Billable fields. Please check this article.

    www.schweda.net/blog_d365.php

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    HI txtxt,

    You need to hide an Enum values Resource category based on the Line Propeties. You can delete the enum at run time of the enter method. Based on the condition you can delete them.

    public void enter()
    {
        super();
        if(DataSourceName.LineProperty == Billable)
        {
            this.delete(enum2str(ResourceCategory::ProjectAllocated));
        }
    }

    Thanks,

    Girish S.

  • Dynamics365Admin Profile Picture
    212 on at

    Hi Mohit

    Since I have to show/hide values based on certain conditions, I have written the following code but I am not sure where to call this method to exceute it correctly. Please have a look on the code and suggest.

    public static Common lookupResourceCategory(FormDataSource _formDataSource, FormControl _formControl)
        {
            // Retrieve the selected value of the Billability field
            str billability = _formDataSource.cursor().INCK_ResourceRequitionLine_Billability;
    
            // Create a new query that retrieves the ResourceCategory values based on the selected Billability
            Query query = new Query();
            QueryBuildDataSource qbdsResourceCategory = query.addDataSource(tableNum(INCI_ResourceCategory));
            qbdsResourceCategory.addRange(fieldNum(INCI_ResourceCategory, Billable)).value(billability == 'Billable');
            qbdsResourceCategory.addRange(fieldNum(INCI_ResourceCategory, ResourceCategoryId)).value(billability == 'NonBill').value(strFmt('!=%1', enum2str(ResourceCategoryId::ProjectAllocated)));
    
            // Create a new lookup that displays the filtered ResourceCategory values
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(INCI_ResourceCategory), _formControl);
            sysTableLookup.addLookupField(fieldNum(INCI_ResourceCategory, ResourceCategoryId));
            sysTableLookup.addLookupField(fieldNum(INCI_ResourceCategory, Name));
            sysTableLookup.parmQuery(query);
    
            return sysTableLookup.performFormLookup();
        }
    
    

    I have written this method in the form data source table.

  • Dynamics365Admin Profile Picture
    212 on at

    Hi Girish,

    Thanks for your response

    Where do I need to write enter method, in the form datasource or in the form control.

    Regards

  • GirishS Profile Picture
    27,827 Moderator on at

    You said resource category as an Enum field. But you have added lookup for that. Is this Enum or string field.

    Seems this is a lookup method - You need to override the lookup method of the Resource category field and add the above code.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    You mentioned Resource Category is an enum, if that's not correct and ResourceCategoryId is a string field then no need to use code in enter (to remove enum values).

    You can use your lookup code on ResourceCategoryId control and add ranges with if condition. You will need two if conditions to check value of Billable field and add range accordingly.

  • Dynamics365Admin Profile Picture
    212 on at

    Thanks for your response.

    Sorry to ask again, but I got a bit confused here, So I would like to rephrase the requirement.

    In the form, I have 2 controls, Billability and Resource category. Billability is of type str and Resource category is of type enum. My requirement is that while creating a new record in the form, If the Billability field is set to Billable, then only Project Allocated option should be visible in the drop down of the Resource Category(i.e. we can only select project allocated option). If the Billability field is set to Non Billable, then all option except Project Allocated should be visible and available for selection in the Resource Category dropdown.

    To achieve this, where and what code is needed. Thanks.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    You need to add your logic in enter method of the control.

    public void enter()
    {
        super();
        if(DataSourceName.Billability == "NonBillable")
        {
            this.delete(enum2str(ResourceCategory::ProjectAllocated));
        }
    }

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Right, so what I understood earlier was correct, you want to remove enum values based on field selection. In that case, you don't need a lookup method, please check the article I shared in first comment and Girish's code above.

    You need to override enter method of ResourceCategory and add two if conditions to check value in Billable field. Delete either one or all except one enum value based on value in Billable field.

  • Dynamics365Admin Profile Picture
    212 on at

    I cannot add new method in the control as it is greyed out.  Do I need to create extension or use COC?

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
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans