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

How to customise SalesTable for to allow user to Enter the ItemId with Barcode Scanner

(4) ShareShare
ReportReport
Posted on by 255
I have a requirement to customise the SalesTable form to allow the user to enter the ItemId with a Barcode scanner on the salesTable form.
 
I have tried a number of ways and places.  The following is the furthest that I got and everyting works except where I want to update the ItemId with the value returned from InventTable.ItemId.  And then I am assuming I will have to refresh the form to show the changed item id.
Can someone help with what I am doing wrong or if there is a better way of doing this. I have added comments to my code where it is going wrong.
Any Advice will greatly be appreciated
 
[ExtensionOf(formControlStr(SalesTable, SalesLine_ItemId))]
final class SalesTableForm_ItemIdControl_???_Extension
{
    public boolean modified()
    {
        boolean             ret;
        FormStringControl   ctrl     = this as FormStringControl;
        ItemId              itemId   = ctrl.text();
        InventTable         inventTable;

        if(itemId != '' && !InventTable::exist(itemId)) // ItemId has been entered but it is not valid InventTable Item
        {
            inventTable = InventTable::find(InventItemBarcode::findBarcode(itemId, False, False).itemId);
            if (inventTable.ItemId != '') //Not an Item found with barcode
            {
                info(StrFmt("Barcode value entered. Item ID: %1.",inventtable.ItemId)); //Optional
                ctrl.text(inventTable.ItemId); // Update the control with the correct Item Id
                //WHEN DEBUGGING THE ctrl.text is ""
                //How do I refresh the form ????????
                
            }
        }
        ret = next modified();
        return ret;

    }

}
 
Categories:
I have the same question (0)
  • Anton Venter Profile Picture
    20,635 Super User 2026 Season 1 on at
    Please explain the requirements in detail to us. Use screenshots etc. (insert them using the insert image button).
  • André Arnaud de Calavon Profile Picture
    303,332 Super User 2026 Season 1 on at
    Hi Sophs,
     
    When the users will scan the barcode, what is the value of this? Are the scanning the item number as known in your released product list, or the manufacturer/EAN number on the package?
     
    In case it is your item number, there might not be any development required. There are barcode scanners as extension for the keyboard. If you then scan a code, it will translate it and perform data entry.
  • Sophs@4Sight Profile Picture
    255 on at
    Hi André and Anton
    Thank you for your response.  We are upgrading our client from AX2012 to Dynamics 365 F&O.  In AX2012 there was custom code which allowed the user to stand on the SalesTable Form SalesLine_ItemId and with the scanner scan the item.  The code (Similar to what I showed above) would then test if it is a barcode or itemid.  If it is a valid barcode then it would replace the barcode value (in the itemId field) with the itemid.
     
    I am very sure that there must be some way to do this already in F&O but I have not been able to find an existing standard solution. André if you can point me to an article or a way that their existing scanners can work I would greatly appreciate it as we are trying to keep customisations to a minimum.
    Preferably we do not want to have to buy new scanners.
     
    Anton
    The requirement is that on the SalesTable form (Accounts Receivable > Orders > All sales orders ) when the user wants to add a new line they want to scan the physical product (example hairdryer) on the counter instead of having to type in or select the itemid from the lookup.  I understand and hope there is a different way, but as I could not find it I was thinking of customizing the SalesTable form on SalesLine_Itemid to allow the user to stand on the Item number field scan the barcode and then the code will test if it is not a valid itemid, see if it is a valid barcode, and if it is valid replace the barcode text in the itemid field with the corresponding itemid. (See code above)  but with this I am a bit stuck after determining the correct itemid how to overwrite formcontrol (SalesLine_ItemId) and refresh the form to show the ItemId value in the Item Id field.
     
  • Suggested answer
    Sophs@4Sight Profile Picture
    255 on at
    So how I have solved this (There might be another way so please feel free to advise)
    I added a new field to salesline ???BarcodeScan which will be used to scan the barcode and in the modified field of the new field we populate the item information and the product information obtained from the barcode table.
    [ExtensionOf(formDataFieldStr(SalesTable,SalesLine,???BarcodeScan))]
    final class SalesTableForm_SalesLineDS_???_Extension
    {
        // If the barcode scan field is modified update the Item Id and clean out the scan field
        public void Modified()
        {
            FormDataSource ds, ds_inventdim;
            FormDataObject df = any2Object(this) as FormDataObject;
            SalesLine salesLine;
            
            next Modified(); // Call original method
                    
            ds          = df.dataSource();
            salesLine = ds.cursor();
    
            if(salesLine.???BarCodeScan)
            {
                InventItemBarcode   inventItemBarcode;
                InventDim           inventDim_barCode;
    
                inventItemBarcode   = InventItemBarcode::findBarcode(salesLine.???BarcodeScan, False, False);
                
                if(inventItemBarcode)
                {
                    ds.object(fieldNum(SalesLine, ItemId)).setvalue(inventItemBarcode.ItemId);
                    ds.object(fieldNum(SalesLine, ItemId)).modified();
                    inventDim_barCode            = InventDim::find(inventItemBarcode.inventDimId);
                    salesLine.InventDimId   = inventItemBarcode.inventDimId;
    
                    InventDim currentInventDim = element.inventdim_ds.cursor();
                    salesLine.???BarCodeScan = '';
    
                    currentInventDim.InventColorId = inventDim_barCode.InventColorId;
                    element.updateProductDimensions(currentInventDim);
                    
                    info(StrFmt("@???:ItemIdBarcode", inventItemBarcode.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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans