Search your query

Thursday, February 2, 2017

X++ code to create file management URL and download the file from Browser

public static void main(Args _args)
{
        DocuRef                     docuReference;
        DocuValue                   docuValue;
        DocuAction                  docuActionClass;
        str                         url;
        Browser                     br = new Browser();
         

        docuReference = DocuRef::find(curExt(), RefRecId) // select the DocuRef table buffer record.

        if(docuReference)
        {
                docuValue = docuReference.docuValue();              
                 url = docuValue.Path;

                if (!url || docuValue.Type == DocuValueType::Others)
                {
                    str accessToken = DocumentManagement::createAccessToken(docuReference);
                    url =           Microsoft.Dynamics.AX.Framework.FileManagement.URLBuilderUtilities::GetDownloadUrl(docuValue.FileId, accessToken);
                }

               if(url)
              {
                     br.navigate(url, false, false); // This code is used to download the file from browser.
              }

1 comment:

  1. Hi Hussain, How are you, Hope you remember me .

    I have a small query on the above query can you help me

    ReplyDelete