D365FO – AX – Copy attachments from Project quotations (SalesQuotationTable) to new or existsing Project (ProjTable) while using “Transfer to project” functionality

We want to copy attachments from Project quotation table to new or existsing project from “Transfer to project” functionality

Create an extension of SalesQuotationProjLinkWizard class

[ExtensionOf(classStr(SalesQuotationProjLinkWizard))]

Create a final class

final class Al0SalesQuotationProjLinkWizard_Extension

{

…………..

}

Create “al0CopyAttachmentsQuotationToProject” custom method.

This method retreieve attachments from SalesQuotationTable to ProjTable.

private void al0CopyAttachmentsQuotationToProject(RecId _SalesQuotationRecId, RecId _ProjTableId)
{
    DocuRef salesQuotationDocuRef;
    //Search if exists an attachment for SalesQuotationTable
    while select  salesQuotationDocuRef
                where salesQuotationDocuRef.RefTableId == tableNum(SalesQuotationTable)
        &&   salesQuotationDocuRef.RefRecId == _SalesQuotationRecId
    {
        //Copy attachment into Project
        DocuRef::createFromDocuRef(salesQuotationDocuRef,_ProjTableId , tableNum(ProjTable));
    };
}

Inside class create a Chain of Command of “linkQuotationToProjectMethod” and call “al0CopyAttachmentsQuotationToProject” method. This will copy attachments to project

public void linkQuotationToProject(ProjId _projId, ProjInvoiceProjId _projInvoiceProjId)
{
    ProjTable           projTableLocal  = ProjTable::find(_projId);
    next linkQuotationToProject(_projId, _projInvoiceProjId);
    //Copy salesQuotationTable attachments to existsing ProjTable
    this.al0CopyAttachmentsQuotationToProject(salesQuotationTable.RecId,projTable.RecId);

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...