46) D365 FO: SHAREPOINT FILE UPLOAD USING X++
Requirement :
Uploading a file in Sharepoint online using X++ and inside from Microsoft Dynamics 365 finance and operations.
Prerequisites:
The current user id of Microsoft Dynamics 365 Finance and operations should have proper rights and privileged in Sharepoint Online.
Sample Code:
In this scenario i am creating a text file in Microsoft Dynamics 365 finance and operations and then uploading its memory Stream in Sharepoint online using X++ . You can modify the X++ code in D365 finance and operations as per your need.
class RunnableClassRun
{
/// /// Runs the class with the specified arguments. ///
/// The specified arguments.
public static void main(Args _args)
{
System.UriBuilder builder = new System.UriBuilder(“https://XXXXXX.sharepoint.com”);
str extId = xUserInfo::getExternalId();
Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider provider;
Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation documentLocation = new Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation();
provider = new Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider(“XXXXXX.sharepoint.com”, “sites/dummy”, “Shared%20Documents/MyFolder”, extId);
System.Byte[] reportBytes = new System.Byte[0]();
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
reportBytes = enc.GetBytes(“YOUR STRING/TEXT”);
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(reportBytes);
//memoryStream = comma.getStream();
documentLocation = provider.SaveFile(newGuid(), ‘TextFile.txt’, System.Web.MimeMapping::GetMimeMapping(‘TextFile.txt’), memoryStream);
}
{
/// /// Runs the class with the specified arguments. ///
/// The specified arguments.
public static void main(Args _args)
{
System.UriBuilder builder = new System.UriBuilder(“https://XXXXXX.sharepoint.com”);
str extId = xUserInfo::getExternalId();
Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider provider;
Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation documentLocation = new Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation();
provider = new Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider(“XXXXXX.sharepoint.com”, “sites/dummy”, “Shared%20Documents/MyFolder”, extId);
System.Byte[] reportBytes = new System.Byte[0]();
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
reportBytes = enc.GetBytes(“YOUR STRING/TEXT”);
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(reportBytes);
//memoryStream = comma.getStream();
documentLocation = provider.SaveFile(newGuid(), ‘TextFile.txt’, System.Web.MimeMapping::GetMimeMapping(‘TextFile.txt’), memoryStream);
}
}
}
hislaoc-ki Kimberly Baloi https://marketplace.visualstudio.com/items?itemName=6trucsovuli.Lacuna-Draft-gratuita-2022
ReplyDeleteguivanfucu
AcrysinVcae-gi Kaylee Castro Crack
ReplyDeleteinarimon
niadiccons-ze Guy Nyhus Get it
ReplyDeletesoftware
click here
rigehihea
MquilaPac-yu_1997 Jay Diaz AVG PC TuneUp
ReplyDeleteIObit Uninstaller Pro 11.6.0.12
Blender 3D 3.2.1
ArtCAM
garfperwifit
fratzonquipo-1994 Shawn Mullies KMS Tools Portable 01.08.2022 by Ratiborus
ReplyDeleteAdobe Camera Raw 14.5
WinRar
Site
brenofesus