Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Simple lookup Customization for Item Unit of Measure

Posted on by 45
Hi All,
 
I got a request from a customer who wishes to hide a unit of measurement option from certain items. The issue here being that the unit of measure that needs to be disabled from use already has item ledger entries. For some reason they do not want to create a new item. For all outbound documents they want to be able to hide a certain unit of measure for a specific item or items. 
 
My approach was:
  1. Extend the item unit of measure table with a boolean field called Hide
  2. Extend the Page Item units of Measure with the same field
  3. Extend Table 37-Sales Line Table - on field 5407-Unit of Measure Code [10]. By changing the table relation property
To my understanding this should be enough to manipulate the lookup behaviour on the Saler Orders Page from with the Sales Lines Sub Form. 
 
here is my table relation Code:
if (Type = const(Item)No. = filter(<> '')) Item Unit of Measure Code where(Item No. = field(/No.))if (Type = const(Item)No. = filter(<> '')) Item Unit of Measure Code where(Item No. = field(/No.), Hide = const(false))
In the edited code I added the /Hide = Const(false)/ into code. I would expect that when looking up the Item unit of measure from the /Unit Of Measure Code/ field on the Sales Line Page, it nof only filters on the /Item No./ = field(/No./), but also on the Hide = Const(false)) field. This does not seem to take effect. 
 
Any suggestions and help would be much appreciated.  The only thing I am still considering is trying to Modify the OnLookUp trigger on the Unit Of Measure Code field on the Sales Order Subform, which has the Sales Line Table as a source. However, I have no idea on what code or logic I should be adding there when I already edited the table relation property for the Unit of Measure Code field on the source table.    
 
Update: 
The code formatter displays the code in a weird way. Here is the code without the code editor:
if (Type = const(Item),
                                No. = filter(<> '')) Item Unit of Measure.Code where(Item No. = field(No.))
            else
            if (Type = const(Resource),
                                         No. = filter(<> '')) Resource Unit of Measure.Code where(Resource No. = field(No.))
            else
            if (Type = filter(/Charge (Item)/ | /Fixed Asset/ | /G/L Account/)) /Unit of Measure/
 
 
--Edited Code
 
if (Type = const(Item),
                                No. = filter(<> '')) Item Unit of Measure.Code where(Item No. = field(No.), Hide = const(false))
            else
            if (Type = const(Resource),
                                         /No./ = filter(<> '')) /Resource Unit of Measure/.Code where(/Resource No./ = field(/No./))
            else
            if (Type = filter(/Charge (Item)/ | /Fixed Asset/ | /G/L Account/)) /Unit of Measure/;
 
Categories:
  • Zafar LIT Profile Picture
    Zafar LIT 45 on at
    Simple lookup Customization for Item Unit of Measure
    Apologies. I will look into the links and feedback and circle back if this solves the problem. I do not seem to be getting any notifications when someone replies. Need to check why that happens. Thank you for your reply.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,864 Super User 2024 Season 2 on at
    Simple lookup Customization for Item Unit of Measure
    Hi, hope the following helps.
    Dynamics 365 Business Central: Can we extend TableRelation Property through a table extension??? (Yes, But…)
     
    However, if you have added a new field, it is recommended to use the Security Filter feature. This way no customization is required, only permissions need to be set.
     
     
    Hope this helps.
    Thanks.
    ZHU

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans