web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,097 Super User 2025 Season 2 on at
    Block enable edit field inventdim_InventLocationId in form x++
    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
    300,716 Super User 2025 Season 2 on at
    Block enable edit field inventdim_InventLocationId in form x++
    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
    Block enable edit field inventdim_InventLocationId in form x++
    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

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 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans