Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Populate value from PO form into VendEditInvoice form

Posted on by 1,209
Hi All,
 
I had a custom table on PO form. I would like to populate some value into VendEditInvoice form when user convert to Invoice. However, when I tried to put my code in the Init method of VendEditInvoice form or Insert method on VendInvoiceInfoTable, but seem none of this is working.
 
What would be the best way to achieve this?

Thanks.

Regards,
Teh
  • YA TEH Profile Picture
    YA TEH 1,209 on at
    Populate value from PO form into VendEditInvoice form
    Hi Andre,
     
    Sorry for late reply. I dont really understand what do you meant by try next custom coding.
     
    Thanks.

    Regards,
    Teh
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,835 Super User on at
    Populate value from PO form into VendEditInvoice form
    Hi Teh,
     
    When reading your code, it might be the case that this.PurchLineRecId does not have a value or an incorrect value. A purchLine record is being retrieved. You can try the next custom coding:
     
    //Custom Code added 09/07/2024
    myCustomTable=MyCustomTable::findPurchLine(purchLine.RecId);
    this.myCustomField=myCustomTable.myCustomFld;
    //Custom Code
    
     
  • YA TEH Profile Picture
    YA TEH 1,209 on at
    Populate value from PO form into VendEditInvoice form
    Hi Andre,
     
    FYI, I'm working on AX 2012 R3 ya, not in D365 F&O. Let me start from beginning what I wan to achieve on VendEditInvoice form.
     
    I had some 1 custom table on PurchTable and 1 custom table  on PurchLine link by their RecId respectively as foreign keys. So when user convert the PO to Invoice. I wanted to copy the value of my field both table to VendtInvoiceInfoTable and VendnvoiceInfoLine table, as I had created custom field on both table as well.
     
    So far, now I managed to copy the value from my custom table on PurchTable into VendEditInvoiceTable, but not on VendEditInvoiceLine table.
     
    On the left hand, the highlighted field is my custom table on PurchLine which link to purchline.recid in my custom table. So when user convert it to invoice for this PO, I wanted to copy the value into right hand form which is the VendnvoiceInfoLine Table on VendEditInvoice form. The field is already added on VendnvoiceInfoLine table.
     
    Below is the code that used in Insert method of VendInvoiceInfoLine table.
     
    /// <summary>
    /// Optionally sets the status of the corresponding <c>PurchLine</c> to be set to Open order as there
    /// is a saved pending invoice against the <c>PurchLine</c>.Optionally activates the Purchase Request
    /// workflow.Create a <c>SourceDocumentLine</c>.
    /// </summary>
    /// <param name="_defaultRelatedTables">
    /// True if related tables should be defaulted on insert; otherwise false. This parameter would
    /// typically be false when <c>VendInvoiceInfoLine</c>records are copied between the saved and active
    /// images of this document.
    /// </param>
    /// <remarks>
    /// Inserting will cause the status of the corresponding <c>PurchLine</c> table to be set to open order
    /// as there is a saved pending invoice against the <c>PurchLine</c> table.
    /// </remarks>
    public void insert(boolean _defaultRelatedTables = true)
    {
        PurchLine               purchLine;
        VendInvoiceInfoTable    vendInvoiceInfoTable = this.vendInvoiceInfoTable();
        //Custom Code added 09/07/2024
        MyCustomTable myCustomTable;
        //Custom Code
        ttsbegin;
    
        // Insert and reference a source document line
        SourceDocumentProcessorFacade::submitSourceDocumentLineImplementation(this);
        
        
        super();
    
        this.SysExtensionSerializerMap::postInsert();
    
        if (this.DocumentOrigin != DocumentOrigin::Service)
        {
            // Only delete tax information if the invoice line is not being inserted via AIF.
            TaxUncommitted::deleteForDocumentHeader(vendInvoiceInfoTable.TableId, vendInvoiceInfoTable.RecId);
    
            // Delete tax Withhold information.
            if (TaxWithholdParameters_IN::checkTaxParameters())
            {
                TaxWithholdUncommitted_IN::deleteForDocumentHeader(vendInvoiceInfoTable.TableId, vendInvoiceInfoTable.RecId);
            }
        }
    
        // Update header round-off amounts.
        vendInvoiceInfoTable.updateFromVendLines();
    
        if (_defaultRelatedTables)
        {
            if (this.isNonPO())
            {
                this.createMarkupTrans(this.vendInvoiceInfoTable());
    
                VendInvoiceInfoLine_Asset::createVendInvoiceInfoLine_Asset(this).insert();
            }
            else
            {
                purchLine = PurchLine::findInventTransId(this.InventTransId, true);
    
                if (purchLine.RecId !=0)
                {
                    purchLine.setPurchStatus(true);
    
                    //COR submit to workflow
                    if(purchLine.PurchaseType == PurchaseType::Purch)
                    {
                        if(purchLine.calcPendingMatchedQtyPurch() < purchLine.calcPendingQtyPurch())
                        {
                            PurchCORInvReceivedWorkflow::submit(purchLine);
                        }
                    }
                    //Custom Code added 09/07/2024
                    myCustomTable=MyCustomTable::findPurchLine(this.PurchLineRecId);
                    this.myCustomField=myCustomTable.myCustomFld;
                    //Custom Code
                }
            }
        }
    
        // <PubSect>
        if (this.isActive())
        {
            this.updateVendInvoiceProjectFromBudgetRes(true, false);
        }
        // </PubSect>
    
        // <GTE>
        if (TaxSolutionScopeIntegrationUtil::isCompanyEnabled())
        {
            this.markCurrentTaxDocumentTaxStatusDirty();
        }
        // </GTE>
    
        ttscommit;
    }
    //Custom Code added 09/07/2024
    MyCustomTable myCustomTable;
    //Custom Code
     
    //Custom Code added 09/07/2024
    myCustomTable=MyCustomTable::findPurchLine(this.PurchLineRecId);
    this.myCustomField=myCustomTable.myCustomFld;
    //Custom Code
     
    I using similar code on the FormDatasource write method or InitFromPurchline method on VendInvoiceInfoLine table. But still no luck.
     
    Thanks.

    Regards,
    Teh
     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,835 Super User on at
    Populate value from PO form into VendEditInvoice form
    Hi Teh,
     
    Can you provide more information? I do assume the Purchase order form extension is working and you have records with correct values in your new table. 
    What exactly do you want to have on the VendEditInvoice form? Do you need to copy values to another custom table or field? What exact coding did you use on the init() and insert() methods?
     

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,835 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans