Tuesday, 18 August 2015

Price Conversion - based on units

public SalesQuoteUOMPrice TotalConversionUnit(UnitOfMeasureSymbol _fromunit,UnitOfMeasureSymbol _tounit,SalesOrderedQty _qty,ItemId _itemid)
{
    SalesQuoteUOMPrice  totalConversionUnit;
    Qty         convertQty;
    UnitOfMeasureConverter_Product  unitConverter   = UnitOfMeasureConverter_Product::construct();

    unitConverter.parmProduct(InventTable::find(_itemid).Product);
    unitConverter.parmFromUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol(_fromunit));
    unitConverter.parmToUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol(_tounit));
    unitConverter.parmRoundAbsoluteValue(NoYes::Yes);
    unitConverter.parmApplyRounding(NoYes::Yes);

    return unitConverter.convertValue(1);

}

Monday, 10 August 2015

Preview Pane creation for LP - Issues

Steps to Create Form Part as Preview Pane :
1.       Create a form , which need to appear as Preview pane. Set Form design properties : Style – Formpart, ViewEditMode – View , Width – Column Width.
2.       Create a Form Part  - Parts >> FormPart >> New
Set Name, Caption,Form – New Form created 1st step.
3.       Create a new menu item of Display Type. Set properties – Name, Label, Object type – FormPart ( Assign the form part created in 2nd step).
4.       Now go to the LP where you need to create a preview pane .
Drag and drop the menu item create in 3rd step in to Parts object of the form.
Set PartLocation – PreviewPane , DataSource – main datasource of the form, DatasourceRelation – SelfLink ( If new form datasource and LP datasource are same, else mention the relation. ), IsLinked – Auto.

We can create Preview Pane using Info part - but with Info part, i got the issue like I have a group field with Note field . When the field have multiple lines,  getting scroll bars, and the field is not extending the total form. 
I tried to set the Repeating property of the Group ( Yes)  - this make the fields in the Group to get Grid View. 

Issue : with setting Yes , for any child record selected, it is getting Note field value for all the records , instead of specific related record. Hence this is can be resolved, only by setting Width of Group which have Note field as - Column width. This can be only possible by R & D in net as creating a Form Part instead of Info Part.

Friday, 7 August 2015

Arrival Create Journal From Arrival Overview and Posting

Functional Process:

To Get Lines in to Arrival Overview - we need to Create Purchase order.

Create Arrival journal(s) from Arrival overview form

1.       User navigates to Stock management / Periodic / Arrival overview
2.       On Arrival overview form,
a.       On Setup tab user sets new ‘Arrival journal per purchase order’ checkbox to ‘yes’
b.       On Overview tab user adjusts range as needed, and selects ‘Update’
3.       On same Arrival overview form, in Receipts section lines are displayed based on previously defined filter criteria ( set – Days Back : 2000 if you want data – click update)
4.       User selects lines (mark them in column ‘Select for arrival’), and calls function ‘Start arrival’
5.       AX prompts user about Arrival journal(s) being created

Register Delivered items on Arrival journal, and post journal

1.       User navigates to Stock management / Journals / Item arrival
2.       Item arrival form opened, user selects journal, and click on ‘Lines’ button.
3.       Journal lines form opened, providing information about:
4.       Click ‘Post’
5.       Posting dialog box displayed. If the user posts an arrival journal with discrepancy 

Technical Overview :

Create Arrival journal(s) from Arrival overview form

>>\Forms\WMSArrivalOverview\Designs\Design\[Tab:Tab]\[TabPage:OverviewTabPage]\[Group:ExpectedReceipts]\[Group:OverviewGroup]\[ActionPane:ActionPane]\[ActionPaneTab:ActionPaneTab]\[ButtonGroup:ButtonGroup]\Button:StartArrivalButton\Methods\clicked

>> Classes\ WMSArrivalStart::startArrival

>> Classes\ WMSArrivalStart\run

wmsArrivalCreateJournal.createWMSJournalTrans(wmsArrivalDetailTmpLocal);  - Journal is created by looping all the selected lines in Lines grid.

>>Classes\WMSArrivalCreateJournal\ createWMSJournalTrans
Line no : 34  - Creates journal header
if (!wmsJournalTable.RecId)
    {
        this.createWMSJournalFromTmp(_wmsArrivalDetailTmp);
    }

Line no  : 52 – Create Journal Lines.

numberOfLines += this.createWMSJournalTransFromTmp(_wmsArrivalDetailTmp);

Post Item Arrival Journal : 

Classes \ WmsJournalCheckPostReception\run
Classes \ WMSJournalCheckPost\main
Classes\ JournalCheckPost\postjournal
 Some Learnings about Classes \JournalCheckPost :
Classes\JournalCheckPost\runEnd – then itself Journal status is updated as posted.
Classes \ WmsJournalCheckPostReception\run  - After Super() – We can make any process that should be done after posting …( Method can be overrided, as it do not exist).
X++ code to create a Item Arrival Journal :

Classes \ WmsJournalCheckPostReception\run   - Get Journal Id through
this.parmJournalId()

Requirements / Modifications :

Create Arrival journal(s) from Arrival overview form

Need to Create separate journals for different Orders
Customization required :
while select wmsArrivalDetailTmpLocal
        where wmsArrivalDetailTmpLocal.Selected   == NoYes::Yes
        &&    wmsArrivalDetailTmpLocal.InventQty  >  0
    {
        find    =   conFind(con,wmsArrivalDetailTmpLocal.InventTransRefId);
        if (!find)
        {
            con = conIns(con,i,wmsArrivalDetailTmpLocal.InventTransRefId);
            i++;
        }
    }
Get all different order ids and loop it by setting Invent TransRefId as range
while select wmsArrivalDetailTmpLocal
            where wmsArrivalDetailTmpLocal.Selected   == NoYes::Yes  // Existing
            &&    wmsArrivalDetailTmpLocal.InventQty  >  0
            && wmsArrivalDetailTmpLocal.InventTransRefId    ==  refrenceId // Add this line as range

Post Item Arrival Journal : 

Need to add new parameter on the post , Based on that we need to create new journal on some validated conditions

In post Dialog Add one more parameter along with Transfer all posting errors to a new journal :

Customization :

1)       Need to add Parm method
2)       Show this field only for Arrival posting : Classes\JournalCheckPost\dialog
wmsjournaltable =   WMSJournalTable::find(journalId);
        if(wmsjournaltable.journalType  ==  WMSJournalType::Reception)
            dialogTransferRemainingQty  = dialog.addField(extendedTypeStr(StockJournalTransferRemainingQuantity));


3)       Need to add the field in Macro – to maintain the value in cache -modify in Unpack and Classdeclaration ( If any error, just remove cache and usage data).
4)       Set parm method in Classes\JournalCheckPost\getFromDialog

Create a new Item Arrival Journal Through code : 

private void CreateArrivalJournal(JournalId _journalId)//JournalTransList _journalTransList)
{
        WMSJournalTable         fromJournalTable,toJournalTable;
        WMSJournalTrans         fromJournalTrans,toJournalTrans;
        str                     journalNum,journalName;
        int                     lineNum = 1;
        NumberSeq               numberSeq;
        WMSJournalName          wmsJournalName;
    ;
        if(this.chkRemaingQtyPerJournal(_journalId))
    {
        select * from fromJournalTable
            where fromJournalTable.journalId    ==  _journalId;

        numberSeq = NumberSeq::newGetNum(WMSParameters::numRefWMSJournalId());
        journalName = WMSParameters::find().receptionJournalNameId;
        journalNum = numberSeq.num();
        wmsJournalName = WMSJournalName::find(journalName);
        ttsbegin;
        toJournalTable.initFromWMSJournalName(wmsJournalName);

        toJournalTable.JournalNameId        =   journalName;
        toJournalTable.JournalId            =   journalNum;
        toJournalTable.journalType          =   WMSJournalType::Reception;

        toJournalTable.inventDimId = InventDim::inventDimIdBlank();
        toJournalTable.insert();
        while select fromJournalTrans
            where fromJournalTrans.journalId    ==  _journalId
        {
            //Condition whether to insert or not the lines
            {
                    toJournalTrans.clear();
                    toJournalTrans.initFromWMSJournalTable(toJournalTable);
                    toJournalTrans.JournalId                =   journalNum;
                    toJournalTrans.LineNum                  =   lineNum;
                    toJournalTrans.TransDate                =   today();
                    toJournalTrans.ItemId                   =   fromJournalTrans.ItemId;
                    toJournalTrans.Qty                      =   fromJournalTrans.StockExpectedQuantity - fromJournalTrans.qty;
                    toJournalTrans.InventDimId              =   fromJournalTrans.InventDimId;
                    toJournalTrans.vendAccount              =  fromJournalTrans.vendAccount;
                    toJournalTrans.inventTransType          =   fromJournalTrans.inventTransType;
                    toJournalTrans.inventTransRefId         =   fromJournalTrans.inventTransRefId;
                    toJournalTrans.inventTransId            =   fromJournalTrans.inventTransId;
                    toJournalTrans.checkPickingLocation     =   NoYes::No;
                    toJournalTrans.createQuarantineOrder    =   NoYes::No;
                    toJournalTrans.inventDimId              =   fromJournalTrans.InventDimId;
                    toJournalTrans.StockExpectedQuantity    =   fromJournalTrans.qty;
                    toJournalTrans.insert();
                    lineNum++;
            }
        }
    ttscommit;       
         info(strFmt("@SYS58788", journalNum));
    }

}


Tuesday, 7 July 2015

Sys operation Framework

https://amazingax.wordpress.com/2012/12/28/simple-use-of-sysoperation-framerwork-in-ax-2012-part-1datacontract/
https://amazingax.wordpress.com/2012/12/29/microsoft-dynamics-ax-2012simple-use-of-sysoperation-frameworkpart-2attribute-based-customization-and-code-based-customization-using-uibuilder-class/
https://amazingax.wordpress.com/2013/01/05/microsoft-dynamics-ax-2012simple-use-of-sysoperation-frameworkpart-3sysoperationservicecontroller-class/

Delete Functions


Use of Cascade, Restricted and Cascade +Restricted (Delete action property for a table)
image018
Example of Cascade
Suppose we have two tables  (Customer & Order) and the relation is of One-To-Many i.e. Customer can have many orders
So on a parent table i.e.(Customer) if I set a delete action property to “CASCADE” for Order table. Then If I go and delete the record from a Customer table. It will also delete all the related records in Order table automatically
Example of Restricted
Suppose we have two tables  (Customer & Order) and the relation is of One-To-Many i.e Customer can have many orders
So on a parent table i.e.(Customer) if I set a delete action property to “RESTRICTED” for Order table. Then If I go and delete the record from a Customer table. It will first check the record in the child table and if exist that warning prompt saying that first we need to delete a record from child table.
Example of Cascade + Restricted
Suppose we have three tables  (Person ,Customer & Order) Now Person is a parent of Customer table, and Customer is a parent of Order table having (One-To-Many) relations
If I set a Delete action property on Person table to “CASCADE” for customer table  and If I set a  Delete Action property on a CUSTOMER table for Order table to “CASCADE +RESTRICTED”.
So if I delete a record from Customer table then It will first check the record in the child table(order table) and if exist that warning prompt saying that first we need to delete a record from child table.
But if I delete a record from Person table it will automatically delete a record in Customer table and all records related to customer table in Order table would also be deleted.

Monday, 6 July 2015

Add a Button For Document Handling on a new AX form

I) To add this functionality you may need to perform following steps. 

Step 1. Open your form in AOT and Go to from Design node. 

Step 2. Add new button group under ActivePanTab. 

Step 3. Add new command button under this new button group. 

clip_image001 

Step 4. Set following properties of this button 

clip_image002 

Now you need to do one functional setup for this new customization 

Step 5: Open below from 
 Organization administration/SetUp-> Document Management -> Active Document Table 

Step 6: Add your table details here and click on Always enable. 

clip_image003

Step 7: So its done now. 
Open your form and click on Attachment button , below form must open. 

clip_image006



II)   Add Menu Item and Pass Datasource :

1.Add a menu item Button in Button Group
2. Set Button Group Property Datasource - with Form Datasource ( main )
3. Attachment - Image ( 2505)
4. MenuItemType- Display
5. Menu ItemName-DocuView
6. Check the DocuRef table and your table is related with Refrecid and RefTableid.