Modify the value of the InMemory type data table in the form

Hi,
After I query the data in the form, I need to click a button to modify the data, but I found that the data is stored in a temporary table of InMemory type. How should I write the code to modify the data?

[FormControlEventHandler(formControlStr(InventAdjTransaction, SalesReturnCostAutoFill), FormControlEventType::Clicked)]
    public static void SalesReturnCostAutoFill_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormRun formRun = sender.formRun();
        FormDataSource                      tmpFormLookUp_ds;
        TmpFormLookUp                       tmpFormLookUp;
        InventTrans                         inventTrans,inventTransTmp;
        InventTransOrigin                   inventTransOrigin,inventTransOriginTFLU;
        tmpFormLookUp_ds = formRun.dataSource("TmpFormLookUp");
        tmpFormLookUp = tmpFormLookUp_ds.cursor();
        update_recordset tmpFormLookUp
        setting
            adjustNow = - inventTrans.CostAmountOperations
        join inventTransTmp
            where inventTransTmp.RecId == tmpFormLookUp.transRecId
        join inventTrans
            where inventTrans.InventTransOrigin == inventTransTmp.MarkingRefInventTransOrigin
            && inventTrans.ItemId == tmpFormLookUp.itemId
            &&  inventTrans.DateFinancial >= DateStartMth(tmpFormLookUp.dateFinancial)
            && inventTrans.DateFinancial <= DateEndMth(tmpFormLookUp.dateFinancial)
            && inventTrans.Qty == - tmpFormLookUp.qty
            && inventTrans.CostAmountOperations != 0
        join inventTransOrigin
            where inventTrans.InventTransOrigin == inventTransOrigin.RecId
            && inventTransOrigin.ReferenceCategory == InventTransType::Purch;  
        
        formRun.doResearch();
    }

To modify the data in the temporary table of InMemory type, you can use the update_recordset statement with the join keyword to join the temporary table with the table that you want to modify. In the provided code, it looks like you are already using this approach to update the tmpFormLookUp table.

To modify the InventTrans table, you can add another join clause to join it with the temporary table, and then use the setting keyword to update the desired fields. Here’s an example:

update_recordset InventTrans
setting
CostAmountOperations = -tmpFormLookUp.adjustNow
join inventTransTmp
where inventTransTmp.RecId == tmpFormLookUp.transRecId
join tmpFormLookUp
where tmpFormLookUp.itemId == inventTrans.ItemId
&& tmpFormLookUp.dateFinancial >= DateStartMth(inventTrans.DateFinancial)
&& tmpFormLookUp.dateFinancial <= DateEndMth(inventTrans.DateFinancial)
&& tmpFormLookUp.qty == -inventTrans.Qty
join inventTransOrigin
where inventTrans.InventTransOrigin == inventTransOrigin.RecId
&& inventTransOrigin.ReferenceCategory == InventTransType::Purch;

This example joins the InventTrans table with tmpFormLookUp on the itemId , dateFinancial , and qty fields. It also joins InventTrans with inventTransOrigin to filter for only the desired transaction types. Finally, it sets the CostAmountOperations field to the negative value of tmpFormLookUp.adjustNow . You can modify this statement as needed to update other fields or join with additional tables.