Thursday, August 11, 2016

Error: Cannot create a record in Relation between purchase lines and request for Quotation lines (PurchOrderRFQLineReference)

// Error:
 Cannot create a record in Relation between purchase lines and request for Quotation lines (PurchOrderRFQLineReference)

Resolution:

static void CheckRFQPo(Args _args)
{
    VendRFQTrans               vendRFQTrans;
    PurchRFQLine               purchRFQLine;
    PurchRFQCaseLine           purchRFQCaseLine;
    PurchLine                   purchLine;
    PurchOrderRFQLineReference purchOrderRFQLineReference;
    int i;
    ;
    //select firstonly vendRFQTrans
        //where vendRFQTrans.Status  == PurchRFQStatus::Accepted
        //join rfqCaseLineRefRecId from purchRFQLine
        //where purchRFQLine.LineNum == vendRFQTrans.LineNum
            //&& purchRFQLine.rfqId   == vendRFQTrans.rfqId
        //exists join purchRFQCaseLine
        //where purchRFQCaseLine.RecId        == purchRFQLine.rfqCaseLineRefRecId
            ////&& purchRFQCaseLine.ReqLineRefId == "{DA03C50D-7458-48B4-9387-BF20108FC2BD}"
            //&& purchRFQCaseLine.rfqCaseId    == "000008"
            //&& purchRFQCaseLine.DataAreaId   == "dat";
//
    //info(strFmt("%1",vendRFQTrans.RecId));
   
    ttsBegin;
    while select forUpdate purchOrderRFQLineReference
            //where purchOrderRFQLineReference.VendRFQTrans == 5637146087
    {
        if(purchOrderRFQLineReference.PurchLineDataAreaID != curext())
        {
            changeCompany(purchOrderRFQLineReference.PurchLineDataAreaID)
            {
                purchLine = PurchLine::findInventTransId(purchOrderRFQLineReference.PurchLineInventTransId,false);
                if(!purchLine)
                {
                    purchOrderRFQLineReference.delete();
                    i++;
                }
            }
           
        }
        else
        {
            purchLine = PurchLine::findInventTransId(purchOrderRFQLineReference.PurchLineInventTransId,false);
            if(!purchLine)
            {
                purchOrderRFQLineReference.delete();
                i++;
            }
        }
       
    }
    info(strFmt("No of record deleted %1",i));
    ttsCommit;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...