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

a validation on item gtin code but facing issue as method is set as wrappable and hookable false.

(0) ShareShare
ReportReport
Posted on by

Could you please guide me with one scenario…
I need to add a validation on item gtin code. By default standard has set it to 14 digit and if user enter any digit lesser than 14 then it adds 0 to make it 14.
For example if we enter 222 then standard will change it to 00000000000222.
The changes I have to make is based on enum value the size should be like if enum US09 is selected and if user enters 787 then it should be changed to 000000787. That means based on enum only 0 will be added and size should not exceed the size written on condition.
My problem is that standard has used a method called formatgtin() in the table inventitemgtin but this method is wrappable(false) and hookable(false).
Also this is being called in standard in update , insert and validatewrite method. How I can add this validation or is there a way to stop formatgtin method from calling and i could call my custom method instead.
 

Please help.
I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at
    Hi Karuna,
     
    Forgot about the standard method.
    Add your whole logic on the OnInsertingEventHandler.
    This method will be called while inserting record in table and it will format gtin number as you coded.
     
    Thanks,
    Girish S.
  • Mohit Rampal Profile Picture
    12,565 Moderator on at
    Hi Karuna, You have to add your logic based on enum value in couple of methods like insert, update, findGTINNumeric, modifiedField etc of InventItemGTIN table, let standard code run and change the value after standard code execution like CoC on modifiedField will work, try OnInsertingEventHandler as Girish mentioned and let us know where you face issues.
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at
    If the same standard format code is mentioned in insert method of table, then you can go for OnInserted event handler which will override the standard code again with your format.
     
    Thanks,
    Girish S.
  • Suggested answer
    vishalsahijwani Profile Picture
    157 on at
    Hi Karuna , 
     
    Since the hookable and wrappable property is already set to False. Its always better to find the place wherever its called - update() , insert() and validateWrite() and just call your custom method. Your custom method should update the value coming into this field. This will help you to lock this value as a final value.
     
    OnIsert Post or pre event handlers will not help as every time these event handlers will be called the standard method will override them eventually.
     
    Try this approach and let me know if this helps. 
     
    Also if this approach helps please mark this answer as a suggested answer. 
     
     

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
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans