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 :
Microsoft Dynamics AX (Archived)

MultiSelect with update on a temporary table

(0) ShareShare
ReportReport
Posted on by 77

Hi,

I'm attempting a modification to the SalesCreateReleaseOrder form with the intention that a user can filter the order lines and then using a multiselect, ask AX to create a release order with the sales quantity automatically pulled from the corresponding sales line.

So far, I have added a new field to SalesCreateReleaseOrderLineTmp, the temporary table that the form uses as a datasource called SalesLineSalesQty, which carries the SalesQty from the corresponding SalesLine entry. I now want the user to select one or more records and then click a button. This would then copy the value from SalesCreateReleaseOrderLineTmp.SalesLineSalesQty into SalesCreateReleaseOrderLineTmp.SalesQty.

However, when attempting to do this, I get an error - 

Cannot edit a record in Order lines (SalesCreateReleaseOrderLineTmp).
The record has never been selected.

 

The code that I'm using (on the form button) is:

void clicked()
{
    MultiSelectionHelper            selectionHelper = MultiSelectionHelper::construct();
    SalesCreateReleaseOrderLineTmp  orderLineTmp;

    super();

    selectionHelper.parmDataSource(SalesCreateReleaseOrderLineTmp_ds);
    orderLineTmp  = selectionHelper.getFirst();

    while (orderLineTmp){
        ttsbegin;
        orderLineTmp.selectForUpdate(true);
        orderLineTmp.SalesQty = orderLineTmp.SalesLineSalesQty;
        orderLineTmp.update();
        ttscommit;
        orderLineTmp = selectionHelper.getNext();
    }

    SalesCreateReleaseOrderLineTmp_ds.reread();
    SalesCreateReleaseOrderLineTmp_ds.refresh();

}

Is anyone able to assist please?

*This post is locked for comments

I have the same question (0)
  • PhilMatthews Profile Picture
    77 on at
    RE: MultiSelect with update on a temporary table

    Hi Rustem,

    Because this will release all of the lines on the blanket order. The user will be dealing with large blanket orders (500+ lines) and creating release orders for 50+ lines.

    The actual process that the user will do is:

    1) Create a release order from the blanket order.

    2) Filter the lines on the Create Release Order form by Customer Reference, and select them all.

    3) Click the button to fill in the Sales Quantity for all of the lines which have not been filtered out.

    4) Create the release order for these lines only.

    Thanks,

    Phil

  • Rustem Galiamov Profile Picture
    8,072 on at
    RE: MultiSelect with update on a temporary table

    So, why you're not setting SalesQty value when SalesCreateReleaseOrderLineTmp data was created in first time?

  • Verified answer
    PhilMatthews Profile Picture
    77 on at
    RE: MultiSelect with update on a temporary table

    The following code works!

    void clicked()
    {
        MultiSelectionHelper            selectionHelper = MultiSelectionHelper::construct();
        SalesCreateReleaseOrderLineTmp  orderLineTmp, orderLineTmpLocal;
    
        super();
        selectionHelper.parmDataSource(SalesCreateReleaseOrderLineTmp_ds);
        orderLineTmp  = selectionHelper.getFirst();
    
        while (orderLineTmp){
            orderLineTmpLocal.data(orderLineTmp);
            orderLineTmpLocal.SalesQty = orderLineTmp.SalesLineSalesQty;
            orderLineTmpLocal.insert();
            orderLineTmp = selectionHelper.getNext();
        }
    
        SalesCreateReleaseOrderLineTmp.setTmpData(orderLineTmpLocal);
        SalesCreateReleaseOrderLineTmp_ds.executeQuery();
    
    }


    Regards,

    Phil

  • PhilMatthews Profile Picture
    77 on at
    RE: MultiSelect with update on a temporary table

    Hi Rustem,

    That of course makes sense from the error that is given, but the setTmpData() method is called in the init method of the form and if I change my while loop to...

       while (orderLineTmp){
    
        info(orderLineTmp.itemid);
    
       }


    ...for example, it outputs all of the ItemId values of the records that I have selected.

    This is not a form that I have created, it is a form which already exists in AX2009 from stock.

    Regards,

    Phil

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at
    RE: MultiSelect with update on a temporary table

    Hi Phil Matthews!

    That because you don't have any records in your orderLineTmp variable. Try to use setTmpData() method.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans