Remove inter-company link for selected sales order line in one clicking

In standard AX 2012, it only allow you to remove inter-company link for one sales line each time.

Requirement:

Remove links for all or selected sales lines in one clicking.

Modification:

  1. Set “MultiSelect” properties to “Yes” for following buttons
    0_MultiSelect

    • “Inventory” button in sales order lines FastTab1_InventoryButton
    • “Remove link” button under inventory button
      2_RemoveLinkButton
  2. Modify “clicked” method of  remove link button same as below
void clicked()
{
    #AviFiles

    SysOperationProgress    progress = new SysOperationProgress();
    MultiSelectionHelper    helper = MultiSelectionHelper::construct();
    int                     recordsCount, remainRecords;
    SalesLine               salesLine_lc;
    ;

    super();

    recordsCount = salesLine_ds.recordsMarked().lastIndex();
    
    remainRecords = recordsCount;
    
    progress.setCaption(strFmt("Remove intercompany link for total %1 lines", recordsCount));
    progress.setAnimation(#AviUpdate);
    progress.setTotal(recordsCount);    
    
    helper.parmDatasource(SalesLine_ds);
    salesLine_lc = helper.getFirst();
    
    while (salesLine_lc.RecId != 0)
    {
        progress.setText(strfmt("Remove the link of line: %1 - item: %2", salesLine_lc.LineNum, salesLine_lc.ItemId));
        
        if (remainRecords > 1)
        {
            TradeInterCompany::removeMarking(salesLine_lc, null);
        }
        else
        {
            TradeInterCompany::removeMarking(salesLine_lc, element);
        }
        
        salesLine_lc = helper.getNext();
        remainRecords--;
        progress.incCount();
    }
    /*
    super();

    TradeInterCompany::removeMarking(salesLine,element);
    */
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s