convert Qty from a Unit to another Unit

protected Qty AI_Convert(Qty _QtyBatch,ItemId _itemId,SalesUnit _itemUnit,SalesUnit _salesUnit )
{
Qty salesQty;

salesQty = UnitOfMeasureConverter::convert(
_QtyBatch,
UnitOfMeasure::unitOfMeasureIdBySymbol(_itemUnit),
UnitOfMeasure::unitOfMeasureIdBySymbol(_salesUnit),
NoYes::Yes,
InventTable::itemProduct(_itemId));

return salesQty;
}

Advertisements

get last WorkFlow Comment. AX 2012

just add this code to tables method and drag it to the grid

display public server str aiComment()
{
WorkflowTrackingStatusTable trackingStatusTable;
WorkflowTrackingTable trackingTable;
WorkflowTrackingCommentTable trackingCommentTable;
WorkflowComment commentLoc = “”, comment;
;

while select trackingStatusTable where trackingStatusTable.ContextRecId == this.RecId join trackingTable
where trackingTable.WorkflowTrackingStatusTable == trackingStatusTable.RecId join trackingCommentTable
where trackingCommentTable.WorkflowTrackingTable == trackingTable.RecId && trackingCommentTable.Comment != commentLoc
{
comment = trackingCommentTable.Comment;
}

return comment;
}

by : _fiant

one PurchReq Line multiple PO

got client that really what one PR line can posting to multiple.

class RequisitionReleaseStrategy\Main

add this code below

//AIFD
if(cekProses)
{
    ttsBegin;
    for (purchReqLine = fds.getFirst(processMarkedRows) ? fds.getFirst(processMarkedRows) : _args.record(); purchReqLine; purchReqLine = fds.getNext())
    {
        select forUpdate purchReqLineLoc where purchReqLineLoc.RecId==purchReqLine.RecId;
        purchReqLineLoc.PurchLineCreated = false;
        purchReqLineLoc.RequisitionStatus = PurchReqRequisitionStatus::Approved;
        if(purchReqLineLoc)
        {
            purchReqLineLoc.update();
        }
    }
    ttsCommit;
}

Query based Report , add parameter dateFrom and dateTo//

//your language script here
[SysEntryPointAttribute(false)]
public void processReport()
{
    Query q;
    QueryRun qr;
    TransDate dateTo,dateFrom;

    AITransporterPerformanceReportContract contract = this.parmDataContract() as AITransporterPerformanceReportContract;

    dateTo = contract.parmDateTo();
    dateFrom = contract.parmDateFrom();

    delete_from aiTmp;
    q = this.parmQuery();
    q.dataSourceTable(tablenum(CustPackingSlipJour)).addRange(fieldnum(CustPackingSlipJour, DeliveryDate)).value(queryRange( dateFrom, dateTo));
    qR = new QueryRun(q);
    while(qR.next())
    {
        // your logic
    }
}