Skip to main content
Dynamics 365 Community / Forums / Finance forum / To reconfirm PO, what ...
Finance forum
Unanswered

To reconfirm PO, what document status is needed ?

editSubscribe (0) ShareShare
ReportReport
Posted on by 898
Hi guys,
 
I'm creating a custom API which the job is to be able to re-confirm PO with before it is re-confirm, I may want to update its prices.
 
May I know what Document Status is applicable in order to run Confirmation against a once confirmed PO ?
 
I'm using this :
//update purchase orderPurchFormLetterParmData          purchFormLetterParmData;purchFormLetterParmData = PurchFormletterParmData::newData(DocumentStatus::Confirmation,                            VersioningUpdateType::Correction);
 
But currently stuck with error like this :
/Function FormLetterParmDataCorrection.parmFormLetterParmData has been incorrectly called./
 
When I tried to debug, it looks it is hit this checking :
 
 
It looks like something with the versioningUpdate, which not allowing to have data update ?
 
May I know is there any specific rule for the Document Status to allow a confirmed PO, to change its data especially the Price. 
And basically may I know how the Re-confirmation PO with X++ looks ?
 
Thanks.
 
 
 
  • Community member Profile Picture
    Community member 898 on at
    To reconfirm PO, what document status is needed ?
    Hi Andre,
     
    Ni, I'm not enabled change management.
     
    The initial of my program is like this :
    purchFormLetterParmData = PurchFormletterParmData::newData(DocumentStatus::PurchaseOrder,
                                VersioningUpdateType::Initial);
                            purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
                            purchFormLetterParmData.createData(false);
                            purchParmUpdate = purchFormLetterParmData.parmParmUpdate();
    
                            purchParmTable.clear();
                            purchParmTable.TransDate                = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
                            purchParmTable.Ordering                 = DocumentStatus::PurchaseOrder;
                            purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
                            purchParmTable.PurchId                  = purchTable.PurchId;
                            purchParmTable.PurchName                = purchTable.PurchName;
                            purchParmTable.DeliveryName             = purchTable.DeliveryName;
                            purchParmTable.DeliveryPostalAddress    = purchTable.DeliveryPostalAddress;
                            purchParmTable.OrderAccount             = purchTable.OrderAccount;
                            purchParmTable.CurrencyCode             = purchTable.CurrencyCode;
                            purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;
                            purchParmTable.DocumentDate             = purchTable.AccountingDate;
                            purchParmTable.Payment                  = purchTable.Payment;
                            purchParmTable.ParmId                   = purchParmUpdate.ParmId;
                            purchParmTable.insert();
                            
                            List         puchLinesList = _request.parmPurchLineList();
    
                            ListIterator literator = new ListIterator(puchLinesList);
    
                            while (literator.more())
                            {
                                MyLineRequest   updateLineRequest;
                                updateLineRequest = literator.value();
                
                                LineNum     lineNum;
                                ItemId      itemId;                          
                                Price       purchPrice;
    
                                lineNum     = updateLineRequest.parmLineNum();
                                itemId      = updateLineRequest.parmItemId();                     
                                purchPrice  = updateLineRequest.parmPurchPrice();
                                                        
                                PurchLine   purchLine;
    
                                select purchLine
                                where purchLine.PurchId == purchTable.PurchId
                                   && purchLine.LineNumber == lineNum
                                   && purchLine.ItemId == itemId;
    
                                if (purchLine)
                                {
                                    purchParmLine.clear();
                                    purchParmLine.InitFromPurchLine(purchLine);
    
                                    purchParmLine.ParmId      = purchParmTable.ParmId;
                                    purchParmLine.TableRefId  = purchParmTable.TableRefId;         
                                    purchParmLine.PurchPrice  = purchPrice;
                                    purchParmLine.setQty(DocumentStatus::PurchaseOrder, false, true);
                                    purchParmLine.setLineAmount();
                                    purchParmLine.insert();
                        
                                    literator.next();
                                }
                                
                                purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
                                purchFormLetter.transDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
                                purchFormLetter.proforma(false);
                                purchFormLetter.specQty(PurchUpdate::All);
                                purchFormLetter.purchTable(purchTable);
                                purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
                                purchFormLetter.parmId(purchParmTable.ParmId);
                                purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
                                purchFormLetter.run();
                            }
     
    By this, the confirmation is done, but when I check, the price is not updated. At first I suspect because I'm using VersioningUpdateType::Initial, so changed to VersioningUpdateType::Correction. But after since, I get that error all time.  "/Function FormLetterParmDataCorrection.parmFormLetterParmData has been incorrectly called./
     
  • Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,045 Super User on at
    To reconfirm PO, what document status is needed ?
    Hi,
     
    In case you have enabled Change management, a user would first need to perform an action called 'Request change'. 

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,045 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,570 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans