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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import files to Document Handling

(0) ShareShare
ReportReport
Posted on by 575

Hi Experts,

          I need to write a Job to Perform document Management in Sales order.

Salesorder ->Salesorder line->Attachment

I need to import any image or textfile from my system to the Salesorder form in the attachment form.Send any gud link or code to perform that.  Thanks in Advance

1222.PNG

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Document Handling

    Have you googled for code? I have seen many examples in past as blog posts.

  • veera seenivasan Profile Picture
    575 on at
    RE: Import files to Document Handling

    Hi Sohaib ,

             www.dynamics101.com/applying-document-management-framework-microsoft-dynamics-ax-2012

    Got some link But i need to write a Job to implement that

  • Verified answer
    Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Import files to Document Handling

    have a look at another blog post given next URL by Ali

    tech.alirazazaidi.com/document-attachment-through-x-code-dynamics-ax-2012-r3

    Read it, go through it and then if you get specific questions, get back here, so we can explain you non-understandable part of code/job

  • veera seenivasan Profile Picture
    575 on at
    RE: Import files to Document Handling

    Thank you Sohaib for your response

  • veera seenivasan Profile Picture
    575 on at
    RE: Import files to Document Handling

    Hi Sohaib,

                    I can understand that code but i cannot import image file.Can you please help me how to do that.

    error:File cannot be attached if i am importing image file .I have attached my code below

    static void DocumentHandling(Args _args)

    {

       Dialog                                  dialog;

       dialogGroup                       dialogGroup;

       DialogBox                         dialogBox;

       DialogField                       SalesID;

       DialogField                       type;

      FileIOPermission permission;

      DocuRef   docuRef;

    DocuActionArchive archive;

    SalesTable      _salesTable;

    str _name;

    dialog = new Dialog("Enter the Item Number");

       //dialogGroup=dialog.addGroup("Product");

     SalesID = dialog.addField(identifierStr(FreeText),"SalesOrderId");

    // docuRef.TypeId = dialog.addField(id);

       //filename =dialog.addField('Filenameopen', 'File Name');

        dialog.run();

       if (dialog.closedOk())

       {

    _name= @"C:\Users\veeramanis\Downloads\Dev (3).pdf";

    select RecId from _salesTable where _salesTable.SalesId like SalesID.value();

    if (_salesTable!=null)

    {

    ttsBegin;

    docuRef.clear();

    docuRef.RefRecId = _salesTable.RecId;

    docuRef.RefTableId = tableNum("SalesTable");

    docuRef.RefCompanyId = curext();

    docuRef.Name =  _name;

    docuRef.TypeId = 'File';

    docuRef.insert();

    archive = new DocuActionArchive();

    archive.add(docuRef, _name);

    info("Attachment inserted successfully");

    ttsCommit;

    }

       }

    }

  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Import files to Document Handling

    Thank you for reverting  on thread. Allow me sometime to get back to you after testing your code. I may take little time, as I am outside right now. I will be getting back to you in few hours.

    Meanwhile other contributors can also help you, if someone can guess the issue quickly

  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Import files to Document Handling

    Hi Michael,

    I have tested your give code, and it worked. I haven't received any error.

    Kindly use below code again, Note that I have changed file name, just for my own ease. I have NOT cleaned code such as variable name conventions etc. just to save my time. Kindly Test  it again and share full error details of your issue.

    static void DocumentHandling(Args _args)
    {
    
        Dialog                          dialog;
        dialogGroup                     dialogGroup;
        DialogBox                       dialogBox;
        DialogField                     SalesID;
        DialogField                     type;
        FileIOPermission                permission;
        DocuRef                         docuRef;
        DocuActionArchive               archive;
        SalesTable                      _salesTable;
        str                             _name;
    
        dialog = new Dialog("Select sales Id");
        SalesID = dialog.addField(extendedTypeStr(SalesId));
        
        dialog.run();
    
        if (dialog.closedOk())
        {
    
        _name= @"C:\Users\\Administrator\Downloads\Whats New in AX2012 R3 CU11.pdf";
    
        select RecId from _salesTable where _salesTable.SalesId like SalesID.value();
    
            if (_salesTable!=null)
    
            {
    
                ttsBegin;
                docuRef.clear();
                docuRef.RefRecId = _salesTable.RecId;
                docuRef.RefTableId = tableNum(SalesTable);
                docuRef.RefCompanyId = curext();
                docuRef.Name =  _name;
                docuRef.TypeId = 'File';
                docuRef.insert();
    
                archive = new DocuActionArchive();
                archive.add(docuRef, _name);
                info("Attachment inserted successfully");
                ttsCommit;
    
            }
        }
    }
    


    /*If you are not sure about coding, tell us your functional requirement in simple words so we can help you to write accurate code.*/

  • veera seenivasan Profile Picture
    575 on at
    RE: Import files to Document Handling

    Hi Sohaib,

                  Thank you for your Response.I am getting error if i am importing image file .if i am importing any text or pdf file i am not receiving any error.

    error:files with the filetype cannot be attached

  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Import files to Document Handling

    I see let me test that also. seems may be you have incomplete setup for document management.

    Allow me to get back to you shortly.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    RE: Import files to Document Handling

    There can be two possible reason for you issue

    1) Forget to mention .extension or file type in file path e.g. .png etc

    file name should be complete with extension e.g. as under

    _name= @"C:\Users\\Administrator\Downloads\CCT.png";

    2) second reason can be non-allowed extension or file type as per setup.

    you can add new extension type at following path

    Organization Administration >> Setup >> Document Management >> Document Management Parameters

    Switch to Tab File Types and now make sure that your extension or file type should be permitted there.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans