D365 F&SCM - Get the Azure Attachment Document URL via X++

 Problem Statement: 

       The user requires that all invoice-related document attachments be accessible from a single location within the voucher transaction window. Based on their needs, the user should be able to view each document by clicking on its corresponding hyperlink.

Fix:

Introduce one display method for fixing this requirement. 

Step 1: Add a single-line text box to the existing voucher transaction window. (FormStringControl: DocValue_AccessInformation)  

Step 2: Use the COC to get the document location.

[ExtensionOf(tableStr(GeneralJournalEntry))]
internal final class GeneralJournalEntry_Extension
{
        [SysClientCacheDataMethod(true)]
        display Str1260 displayVendorTransactionAttachment()
        {
            DocuValue           docuValue;
            Str1260             accessInformation ='';
            docuValue       = this.getDocuAttachment(this.getvendTransTable());
            if(docuValue)
            {
                 accessInformation   = docuValue.AccessInformation;
            }
           return accessInformation;
        }
        
        VendTrans getvendTransTable()
        {
            VendTrans           vendTrans;
            Select * from vendTrans
                where vendTrans.Voucher       == this.SubledgerVoucher
                    && vendTrans.DataAreaId == this.SubledgerVoucherDataAreaId
                    && vendTrans.TransDate   == this.AccountingDate;
            return vendTrans;
        }

     DocuValue getDocuAttachment(VendTrans _vendTrans)
    {
        DocuRef             docuRef;
        DocuValue           docuValue;
        Select * from docuValue
            join docuRef    
                    where docuValue.RecId        == docuRef.ValueRecId
        && docuRef.RefRecId                     == _vendTrans.RecId  ;
        return docuValue;
    }
}

Step 3:  Set the following Property for the newly added                                      FormStringControl: DocValue_AccessInformation

            Data Source as "GENERALJOURNALENTRY" 

            Data method as "GeneralJournalEntry_Extension.displayVendorTransactionAttachment"

Step 4: Introduce a new EventHandler for enabling the Hyperlink options.

        internal final class LedgerTransVouchers_EventHandler

        {
                   FormControlEventHandler(formControlStr(LedgerTransVouchers,                                  DocValue_AccessInformation), FormControlEventType::JumpRef)]
            
        public static void DocValue_AccessInformation_OnEnter(FormControl sender,             FormControlEventArgs e)
        {
                FormStringControl urlControl = sender as FormStringControl;
                str documentUrl = urlControl.text();
                if (documentUrl && strLen(documentUrl) >0 )
                {
                    Browser browser = new Browser();
                    browser.navigate(documentUrl, true); // true = open in new tab
                }
        }
    }

Step 5: Build and Sync the Database.

Step 6: Now user able to access the document location via hyperlink.

Comments

Popular posts from this blog

DMF (1073676279) - Issue Fix

Read the JSON data via REST API (X++)