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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Block enable edit field inventdim_InventLocationId in form x++

(1) ShareShare
ReportReport
Posted on by 73
Hallo i have question,
Is it possible to disable editing fields in the INVENTDIM table?
 
I've tried using the eventhandler and also the form extension but the warehouse column can always be edited.
I just want to lock the column so it can't be edited when the itemid(InventJournalTrans.itemid) starts with 'FG'. because it is automatically filled according to the default warehouse that we set for the item.
 
 
is there any input?is there any input?
I wrote a line of code like this, and it didn't work
[ExtensionOf(formDataSourceStr(InventJournalBOM,InventJournalTrans))]
internal final class InventJournalTrans_Extension
{
    int active()
    {
        int ret;
        ret = next active();
        InventJournalTrans  InventJournalTrans;
        InventJournalTrans  = this.cursor();
        FormRun             formRun;
        formRun             = this.formRun();
        str itemID = subStr(InventJournalTrans.ItemId,1,2);
        if(itemID == 'FG')
        {
            formRun.control(formRun.controlId(formControlStr(InventJournalBOM, InventoryDimensions_InventLocationId))).allowEdit(false);
        }
        return ret;
    }
}
 
I have the same question (0)
  • Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi Dodi,
     
    Did you debug and see what is returned in "ItemId" and if it enters the if condition?
     
     
    Thanks,
    Layan Jweihan 
  • André Arnaud de Calavon Profile Picture
    303,724 Super User 2026 Season 1 on at
    Hi Dodi,
     
    Like Layan mentioned, you can use the debugger to check the behavior. Note that the editability of these columns are also managed with coding that checks if a dimension is active for a particular item. It might be the case that the standard coding is overriding the outcome of your extension. 
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Check enableButtonsActive() method in JournalFormTable. This is actually controlling all the controls in this form.
     
    From your code, if you want to disable a field, you need to write something like this
    InventJournalTrans  inventJournalTrans_ds = this as InventJournalTrans;
    InventJournalTrans  inventJournalTrans = inventJournalTrans_ds.cursor();
    str itemID = subStr(inventJournalTrans.ItemId,1,2);
    
    inventJournalTrans_ds.object(fieldNum(InventDim, InventLocationId)).allowEdit(itemID != 'FG');
     
    As Layan suggested, debug it and check if FG is actually shown up in itemId.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans