Notifications
Announcements
No record found.
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
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
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.
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.
Hi Girish,
Thanks for your response
Where do I need to write enter method, in the form datasource or in the form control.
Regards
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.
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.
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.
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)); } }
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Abhilash Warrier 669 Super User 2025 Season 2
André Arnaud de Cal... 449 Super User 2025 Season 2
Martin Dráb 384 Most Valuable Professional