web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

To Pass the attachemnt from one form to another

(0) ShareShare
ReportReport
Posted on by 1,836
I have created button on customise from which on click pass add the files in attachment , but at the same time i want to add the same attachment to custinvoicejour record both record have invoice id and invoice date same , please suggest me how can i get this done, can any one help me on this . 
below is my code .
thanks ,
Regards,
Dinesh
 
 
 
I have the same question (0)
  • Dineshkarlekar Profile Picture
    1,836 on at
     class DTDMCLinesAttachment
    {
        public static void main(Args _args)
        {
            FileUploadTemporaryStorageResult  result;
            DTDMCHeaderLines      dTDMCHeaderLines;
            CustInvoiceJour       custInvoiceJour;
            DocuRef               docuRef2;
            dTDMCHeaderLines = _args.record();
     
            result = File::GetFileFromUser(classStr(FileUploadTemporaryStorageStrategy));
            if(result != null)  /* result.getUploadStatus()*/
            {
                str fileName = result.getFileName(); //Insert the name of the attachchment
    
                using(System.IO.MemoryStream stream = result.openResult() as System.IO.MemoryStream)
                {
                    DocuRef docuRef = DocumentManagement::attachFile(
                                 dTDMCHeaderLines.TableId,
                                 dTDMCHeaderLines.RecId,
                                 dTDMCHeaderLines.DataAreaId,
                                "DailyCollectionattachment",
                                stream,
                                fileName,
                                System.Web.MimeMapping::GetMimeMapping(filename),
                                fileName);
                    select * from custInvoiceJour
                        where custInvoiceJour.InvoiceId == dTDMCHeaderLines.InvoiceId;
    
                    buf2Buf(docuRef,docuRef2);
                    docuRef2.RecId = 0;
                    docuRef2.RefTableId =  custInvoiceJour.TableId;
                    docuRef2.RefRecId =  custInvoiceJour.RecId;
                    docuRef2.insert();
                    
                   
                }
            }
     
        }
    
    }
     
  • Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    So if you have code that inserts attachments to let's say table1 and it's working correctly. Can't you write similar code to also insert to custInvoiceJour?
     
    Thanks,
    Layan Jweihan
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at
  • André Arnaud de Calavon Profile Picture
    300,896 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Can you describe the current behavior of your coding? Do you get an error? Is the attachment for one or both of the tables missing? Have you already used the debugger to find any possible issues?
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    everyone ,
    thanks for reply ,
     
    i have debug the issue , i am getting the the error , the file type does  not exists , i need to configure share point settings so i can proceed further .
    can you please tell me do i have to add new relation between my custom table and cust invoice jour , so if yes which fields should i use for  relation  to get required results , do i have to make any changes in index , please suggest me on this .
     
    thanks,
    regards,
    Dinesh
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    Everyone 
    I have written the code on the extension of custinvoice jour. please let me what changes i need to de in code .   
     
     class DTDMCLinesAttachment
    {
        public static void main(Args _args)
        {
            FileUploadTemporaryStorageResult  result;
            DTDMCHeaderLines      dTDMCHeaderLines;
            CustInvoiceJour       custInvoiceJour;
            //DocuRef               docuRef2;
            DocuType              docuType;
            dTDMCHeaderLines = _args.record();
            docuType = DocuType::find('Image');
            CustInvoiceId       invoiceId;
    
            invoiceId = dTDMCHeaderLines.InvoiceId;
    
            select * from custInvoiceJour
                        where custInvoiceJour.InvoiceId == invoiceId;
     
            result = File::GetFileFromUser(classStr(FileUploadTemporaryStorageStrategy));
            if(result != null)  /* result.getUploadStatus()*/
            {
                str fileName = result.getFileName(); //Insert the name of the attachchment
    
                using(System.IO.MemoryStream stream = result.openResult() as System.IO.MemoryStream)
                {
                    DocuRef docuRef = DocumentManagement::attachFile(
                                 dTDMCHeaderLines.TableId,
                                 dTDMCHeaderLines.RecId,
                                 dTDMCHeaderLines.DataAreaId,
                                docuType.TypeId,
                                stream,
                                fileName,
                                System.Web.MimeMapping::GetMimeMapping(filename),
                                fileName);  
                }
    
                custInvoiceJour.doUpdate();
            }
     
        }
    
    }
     
    ExtensionOf(tableStr(CustInvoiceJour))]
    final class DTCustInvoiceJourTbl_DmcAttachment_Extension
    {
        public void doUpdate()
        {
            next doUpdate();
            
            DTDMCHeaderLines dTDMCHeaderLines = DTDMCHeaderLines::find(this.InvoiceId);
            CustInvoiceJour  custInvoiceJour;
    
            DocuRef docuRef = DocuRef::findTableIdRecId(dTDMCHeaderLines.DataAreaId, dTDMCHeaderLines.TableId, dTDMCHeaderLines.RecId);
            ttsbegin;
            custInvoiceJour.selectForUpdate(true);
            custInvoiceJour.reread();
    
            if (docuRef)
            {
                docuRef.RefTableId = this.TableId;
                docuRef.RefRecId = this.RecId;
                docuRef.insert();
            }
            custInvoiceJour.doUpdate();
            ttscommit;
        }
    
    }
    
     
    thanks,
    Regards,
    Dinesh.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Did you try your code? What is the result? I can see on your code:
     
     CustInvoiceJour       custInvoiceJour; ---- Empty buffer and it wasn't used.
     
    Thanks
    Waed Ayyad,
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Verified answer
    Dineshkarlekar Profile Picture
    1,836 on at
    hi , everyone 
     
    Thanks for reply ,
     
    i was not getting the value attached in custinvoiced jour .
    now i am getting the attachement copy .
     
    Thanks,
    Regards,
    Dinesh

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 540 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans