03 June 2011

Update planned order upon modified salesline

Business requirement: update planned order
upon modification of a salesline
without master scheduling

Sometimes you want to see changes made on a SalesLine immediately on the
reference Planned Order, without Master Scheduling. This post describes
how you can make a little code adaptation to achieve this. The changed planned
order belongs to the dynamic master plan, which seems most logic in
these cases.

Solution: X++ code to be added

Add following method to the class SalesLineType and call it in the update
method of the class SalesLineType.

void synchPO (SalesLine _salesLine) 
{
    ReqPO reqPO;
    ;

    reqPO = ReqPO::find(ReqPlanSched::defaultDynamicId(),
_salesLine.reqTrans().reqTransSettled(
salesLine.reqTrans().selectCov()).RefId
,true);

if (reqPO)
{
// whatever field in reqPO to be updated based on
// some information on the referenced SalesLine
reqPO.Qty = _salesLine.SalesQty;
if (reqPO.validateWrite()
reqPO.update()
}
}

1 comment:

  1. Good Job Patrick, thanks ! :)

    Except the first parameter of the void "ReqPlanSched::defaultDynamicsId()".

    It doesn't work ; so I replaced it by : "ReqPlanVersion::findActiveReqPlanIdDynamic().RecId"

    ++

    ReplyDelete