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, ...
Answered

Write to form DS with InMemory table failed

(1) ShareShare
ReportReport
Posted on by 3,262
Extension made for table WHSTmpLoadLineInventory (InMemory) with two fields. Used on form WHSUnshipLoadLine.Extension.
The user can now choose the unship location and license plate per line and unship with one function.
For convenience onModified handler is added to initialize all the fields with the value of location.
 
 
[FormControlEventHandler(formControlStr(WHSUnshipLoadLine, ToLocation), FormControlEventType::Modified)]
public static void ToLocation_OnModified(FormControl sender, FormControlEventArgs e)
{
    WHSTmpLoadLineInventory tmpLoadLineInventory;
    FormDataSource formDS;
    FormStringControl control = sender as FormStringControl;
    info(control.valueStr()); // ok
    
    formDS = sender.formRun().dataSource(1);
    tmpLoadLineInventory = formDS.getFirst() as WHSTmpLoadLineInventory;
    
    while (tmpLoadLineInventory)
    {
        tmpLoadLineInventory.CustWMSLocationId = control.valueStr();
        tmpLoadLineInventory.write(); // error
        tmpLoadLineInventory = formDS.getNext() as WHSTmpLoadLineInventory;
    }
    
    formDS.reread();
    formDS.refresh();
    
}
 
On tmpLoadLineInventory.write() the error occured: Cannot edit a record in Temp Load Details Inventory Breakdown (WHSTmpLoadLineInventory). The record has been deleted by another user.

Is this not possible because of the in memory table type?
I have the same question (0)
  • Hana Xue Profile Picture
    Microsoft Employee on at
    Hi,
    Please check the old thread with similar problem to yours.
    https://www.dynamicsuser.net/t/updating-tempdb-table/61688          
    Best Regards,
    Hana
  • Verified answer
    Jan M. Profile Picture
    3,262 on at
    Changed the handler to call only executeQuery() and added the code in a datasource extension.
    There the buffer is copied and the result should be applied to the form datasource.
     
    [ExtensionOf(formDataSourceStr(WHSUnshipLoadLine, WHSTmpLoadLineInventory))]
    final class CustWHSUnshipLoadLineFrmCtrl_Extension
    {
        public void executeQuery()
        {
            FormDataSource formDS = any2Object(this) as FormDataSource;
            WHSTmpLoadLineInventory tmpLoadLineInventory, tmpLoadLineInventoryTmp;
            FormStringControl control;
            boolean ret;
            
            control = this.formRun().design().controlName(formControlStr(WHSUnshipLoadLine, ToLicensePlate));
            tmpLoadLineInventory = formDS.getFirst() as WHSTmpLoadLineInventory;
            tmpLoadLineInventoryTmp.setTmp();
            while (tmpLoadLineInventory)
            {
                tmpLoadLineInventoryTmp.data(tmpLoadLineInventory);
                tmpLoadLineInventoryTmp.CustWHSLicensePlateId = control.valueStr();
                tmpLoadLineInventoryTmp.doInsert();
                tmpLoadLineInventory = formDS.getNext() as WHSTmpLoadLineInventory;
            }
            //whsTmpLoadLineInventory.setTmpData(tmpLoadLineInventoryTmp); // not valid in this context
            
            formDS.setRecord(tmpLoadLineInventoryTmp);
            
            formDS.refresh();
            next executeQuery();
        }
    }
     
    The error is gone but the form still doesn't show the values. It should with formDS.setRecord(tmpLoadLineInventoryTmp)?
    Standard writes to the form datasource in the init() with whsTmpLoadLineInventory.setTmpData(tmpLoadLineInventoryTmp, what cannot be used there.
    How the result can be applied to the form datasource?
     
  • Verified answer
    Jan M. Profile Picture
    3,262 on at
    Solution: Form Extension added with a method to get the datasource.
     
    After the loop (post April 9) you will have to have to add this line:
    tmpLoadLineInventory = formRun.GetWHSTmpLoadLineInventoryDS(); // get form datasource
    tmpLoadLineInventory.setTmpData(tmpLoadLineInventoryTmp); // writes data back
    formDS.research();
    formDS.refresh();

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans