Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Block enable edit field inventdim_InventLocationId in form x++

(1) ShareShare
ReportReport
Posted on by 69
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;
    }
}
 
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 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.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,791 Super User 2024 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. 
  • Layan Jwei Profile Picture
    Layan Jwei 7,278 Super User 2024 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 

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,791 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,488 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans