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, ...
Suggested Answer

Expose image(png,jpg) value (DocuRef, DocuValue>AccessInfo) to 3rd party system

(0) ShareShare
ReportReport
Posted on by 85

Hello 

I would like to send the image (or) url of the image which we generally attach to records attachment in D365F&O (DocuRef, DocuValue tables) to the 3rd party system

I did try using ==> DocuAction d = attachedDocuRef.docuAction(); and d.getPublicUrl(docuRef), but that image file never be found... ?

any solution please?

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi RahulD365,

    Do you mean that you get URL, but if you try to open, you can't access the file?

  • RahulD365 Profile Picture
    85 on at

    yes

  • WillWU Profile Picture
    22,361 on at

    Hi RahulD365,

    Please check the getAttachmentPublicUrl method in the DocumentManagement class:

    str displayUrl = DocumentManagement::getAttachmentPublicUrl(docuRef);
    Browser br = new Browser();
    br.navigate(displayUrl);
    

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi,

    We have custom service to send the attachment data code is like below, you can use the same code:

    data is the custom object where all the values are set and returned to service, you will need to update the code as per your requirements.

    if (docuRef.isValueAttached())
    {
    	DocuValue docuValue = docuRef.docuValue();
    	URL url = DocumentManagement::getAttachmentPublicUrl(docuRef);
    
    	if (docuValue.Type == DocuValueType::Others)
    	{
    		//For sharepoint files -> we get convert internal system.net.connectStream to memoryStream and return byte
    		if(docuValue.StorageProviderId == DocuStorageProviderType::SharePoint)
    		{
    			using (System.IO.Stream connectStream = DocumentManagement::getAttachmentStream(docuRef))
    			{                                        
    				using (var ms = new System.IO.MemoryStream())
    				{
    					connectStream.CopyTo(ms);                                            
    					byteArray = new System.Byte[ms.Length]();
    					ms.Read(byteArray,0,ms.Length);
    				}
    			}
    			data.parmByte(byteArray);                                    
    		}
    		//For azure blob
    		else
    		{
    			using (System.IO.Stream fileStream = DocumentManagement::getAttachmentStream(docuRef))
    			{
    				byteArray = new System.Byte[fileStream.Length]();
    				fileStream.Read(byteArray, 0, fileStream.Length);
    			}
    			data.parmByte(byteArray);
    		}
    	}
    }
    data.parmPublicURL(url);
    data.parmStorageProvider(enum2Str(docuValue.StorageProviderId));
    data.parmAccessInformation( docuValue.AccessInformation);
    data.parmFilename(docuRef.filename());
    data.parmfiletype(docuRef.fileType());
    data.parmTypeId(docuRef.docuType().TypeId);

  • RahulD365 Profile Picture
    85 on at

    Thanks Vinit, and do you have code to create the attachment from 3rd party? Like how to read the image from 3rd party? using container ?

  • RahulD365 Profile Picture
    85 on at

    Thanks Will, but I see my downloaded str is something like this - filemanagement/834er32c-1497-4114-86c6-6221762b76b6?access_token=eyJDb21wYW55IjoiVVNTSSfffkhhc2hlZFRva2VuIjo................

    but I cant browse this/or find the image associated? Can i get absolute url?

  • WillWU Profile Picture
    22,361 on at

    Hi RahulD365,

    Please check the getPreviewUrl() method in the class docuManagement.

    docuURLprev = docuManagement.getPreviewUrl(docuRef);

    Why you have to preview the image. You shouldn't focus on the urls , just work with them.

  • RahulD365 Profile Picture
    85 on at

    Anyone knows - how to import the image data from 3rd party to D365 F&O ?

    As said, I'm going to store the image in docuRef, but let's say using FormPart (postman) I upload the image and this needs to be attached to D365 Docuref record?

    Any idea?

  • RahulD365 Profile Picture
    85 on at

    Will, 3rd party need to have the URL so that they can download, I managed for the full URL but its not that concrete.

  • RahulD365 Profile Picture
    85 on at

    Can Anyone help?

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 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans