One form SalesTable with two menuItemName

Background :

We want to create Sales Order , from SalesTable form, with sales type : Returned Order, automatically without user choose Sales Type.

How to :

Create new menu item to open SalesTable form, then every new created record in SalesCreateOrder, it should be read the new name of menu item, then save it to SalesTable table with type of sales : Returned Order.

Details :

1. create new item name, let say for example : IT_ReturnOrder.

Object Type : Form

Object : SalesTable

EnumTypeParameter : SalesTableFormId

EnumParameter : None

RunOn : Called from

2. edit method ‘init’ in SalesTable form, after this code :

salesTableForm = SalesTableForm::construct((element.args().parmEnumType() ? element.args().parmEnum() : maxint()),
                                                element.args().record());

add this code :

salesTableForm.setItemNameCaller(element.args().menuItemName());

3. open SalesTableForm class, add new variable in ClassDeclaration method and create 2 new methods :

3.1. add new variable : ClassDeclaration

menuItemName        menuItemName;

3.2. new method : getItemNameCaller

MenuItemName getItemNameCaller()
{
;
    return menuItemName;
}

3.3. new method : setItemNameCaller

public void setItemNameCaller(menuItemName _menuItemName)
{
 ;
    menuItemName = _menuItemName;
}

4. Open SalesCreateOrder form datasource, SalesTable table. Add this code in ‘write’ method :

        if(salesTableForm.getItemNameCaller() == 'IT_ReturnOrder')
        {
            salesTable.SalesType = SalesType::ReturnItem;
        }

5. Done.


About this entry