Document Management Archives - Aric Levin's Digital Transformation Blog https://aric.isite.dev/tag/document-management/ Microsoft Dynamics 365, Power Platform and Azure Thu, 12 May 2022 03:18:29 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 Document Generation Enhancements in 2020 Release Wave 2 https://aric.isite.dev/dynamics/post/document-generation-2020wave2/ Thu, 20 Aug 2020 18:12:00 +0000 https://aric.isite.dev/index.php/2020/08/20/document-generation-enhancements-in-2020-release-wave-2/ With the release of Microsoft Dynamics 365 and Power Platform 2020 Release Wave 2, Microsoft has made some enhancements to the document generation capabilities and file attachments in model-driven apps. This first post will cover the document generation capabilities and the generation of pdf documents based on document templates.

The post Document Generation Enhancements in 2020 Release Wave 2 appeared first on Aric Levin's Digital Transformation Blog.

]]>
With the release of Microsoft Dynamics 365 and Power Platform 2020 Release Wave 2, Microsoft has made some enhancements to the document generation capabilities and file attachments in model-driven apps. This first post will cover the document generation capabilities and the generation of pdf documents based on document templates.

In the previous wave, several entities were enabled for pdf creation and export, which included Account, Contact, Lead, Opportunity, Quote, Order and Invoice. In the new release, this has been extended to include also custom entities.

If you are new to this feature, then the prerequisite to the generation of pdf documents is the creation of document templates. You can have one or more document template per entity, and once created you can enable the entity for pdf export functionality. Let’s go over how to create this. We will use the account entity for this purpose, as it already has the Account Summary template associated with the entity.

If you choose a custom entity, you should create a document template first, and then enable the pdf functionality for that entity. If you want to create a document template navigate to the Power Platform Admin Center (https://aka.ms/ppac), select your environment and click on Settings on the Command Bar. In the Settings window, expand Templates and then click on the Document templates link. This link will redirect you to the Document Templates view (still in classic interface at the time of writing this post). Once created, you should be able to use that template for your export to pdf functionality.

Now, let’s go back and enable the account entity for Export to PDF. We do this by first going to the Sales Hub App. From make.powerapps.com, select your environment and click on the Apps navigation link on the left hand side navigation. Click on the Sales Hub App to open the app in a new tab. Once the app is open, change the selected area from Sales to App Settings. Click on the Productivity Tools subarea under General Settings. This will show you the available Productivity Tools, where you will see Convert to PDF as one of the options. Click on Manage in order to add your entity to the available entities for Export to functionality.

Dynamics 365 2020 Wave 2 Release PDF Document Export

From here scroll down to the required entity (or entities), in our case this will be the account entity, and check the box next to the entity name, and the click Save (as shown in the image below).

Dynamics 365 2020 Wave 2 Release PDF Document Export Settings

Once this is saved, your entity should now be enabled for export to pdf. Change your area back to Sales, and navigate back to the account entity. You should now see the Export to PDF command bar button when you open your entity form record. If it is not visible on the Command Bar, click on the more command button (the three vertical dots at the end of the command bar). Once clicked, this will show the Export to pdf modal window, where you will be able to download, email or save the document to SharePoint. The window also contains a preview, so that you can print the document directly from the browser. If you have multiple templates, you can select the template to use for this record as well. The image below shows the resulting dialog and available options that will allow you to generate your pdf document and Save, Email or Print the document.

Dynamics 365 2020 Wave 2 Release Plan - Export to PDF functionality

The post Document Generation Enhancements in 2020 Release Wave 2 appeared first on Aric Levin's Digital Transformation Blog.

]]>
SharePoint Documents are back in Dynamics Portals October 2018 Release https://aric.isite.dev/dynamics/post/sharepoint-documents-dynamics-portals-october-2018/ Tue, 24 Jul 2018 13:38:00 +0000 https://aric.isite.dev/index.php/2018/07/24/sharepoint-documents-are-back-in-dynamics-portals-october-2018-release/ Ever since Microsoft purchased AdxStudios and replaced the product with Dynamics Portals, one of the biggest pains was the removal of SharePoint documents. The interim solution of course was available using Azure blobs with the Dynamics Labs solution which provided document uploads, but using the Out of the Box SharePoint Documents was a miss by a lot of Portal Developers.

The post SharePoint Documents are back in Dynamics Portals October 2018 Release appeared first on Aric Levin's Digital Transformation Blog.

]]>
Ever since Microsoft purchased AdxStudios and replaced the product with Dynamics Portals, one of the biggest pains was the removal of SharePoint documents. The interim solution of course was available using Azure blobs with the Dynamics Labs solution which provided document uploads, but using the Out of the Box SharePoint Documents was a miss by a lot of Portal Developers.

WIth the announcement of the October 2018 release of Microsoft Dynamics 365 (version number yet to be determined), which includes a mass number of features, one of the features that was included was management of SharePoint documents inside Dynamics portals.

This feature extends the document management capabilities of Dynamics 365 to portals, providing a consistent experience and allowing users to leverage their investment in SharePoint with Dynamics 365 for document management. Documents that are associated with entity records can be managed by portal users and stored in the SharePoint document library, providing seamless collaboration capabilities offered natively by SharePoint. SharePoint document libraries configured with entities in Dynamics 365 can be surfaced via the portal entity and web forms.

The additional of SharePoint documents for portals provides the following features:

  • Adding documents to a SharePoint Library via Portals
  • Viewing and downloading documents in a SharePoint Library via Portals
  • Creating folders in a SharePoint Library via Portals
  • Deleting documents in a SharePoint Library via Portals

The screenshot below shows adding a new file to the document library, a much cleaner interface than the existing Azure blob (notes) option.

Portal SharePoint Documents

Enjoy reading the new features that are available in the October 2018 release of Dynamics 365 available here. You can also download the 236 page pdf which contains the contents of the link and the features in this release.

The post SharePoint Documents are back in Dynamics Portals October 2018 Release appeared first on Aric Levin's Digital Transformation Blog.

]]>
Dynamics 365 and SharePoint Online Integration – Web Api Development https://aric.isite.dev/dynamics/post/dynamics-365-sharepoint-online-integration-webapi/ Wed, 28 Feb 2018 12:55:00 +0000 https://aric.isite.dev/index.php/2018/02/28/dynamics-365-and-sharepoint-online-integration-web-api-development/ dynamics-365-sharepoint-online-integration-webapi

The post Dynamics 365 and SharePoint Online Integration – Web Api Development appeared first on Aric Levin's Digital Transformation Blog.

]]>
Now that we have configured our SharePoint and Azure environments to allow us to create an API that will be called from CRM and process SharePoint requests, we will dive into the actual API.

If you haven’t developed any API projects with Visual Studio, I would suggest familiarizing yourself with Web API, and take a look at the following Microsoft Documentation: Getting Started with ASP.NET Web API 2 (C#).

The Web Api projects contains the following components which we will get into further details in this post:

  • References to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime
  • Reference to CAML Query Builder. This is a modified version of the CAML Query builder that is available on github: https://github.com/noormahdi/CAML-Query-Builder
  • Controller classes for DocumentLibrary and LookupItems
  • Model classes for LookupItem, SharePointDocument and SharePointFolder
  • Helper classes for dealing with File Upload, Data, Encryption, and SharePoint

As the API library contains a lot of different functionality, I will go through the process of retrieving the documents API to show in the subgrid. The full source code and instruction on how to use will be available soon on github, so that you can implement this in your own environment. We will start by taking a look at one of the HttpGet methods in our Api Library. This is the starting point that the user will execute against the Api and get a response of the list of documents that are available on SharePoint.

[HttpGet]
[Route("api/Library/GetByMasterId/{id}")]
public HttpResponseMessage GetByMasterId([FromUri] string id)
{
	string authorizationString = DecodeAuthorizationString();
	SPHelper.SetSharePointCredentials(authorizationString);

	List<SharePointDocument> files = new List<SharePointDocument>();

	ListItemCollection list = SPHelper.GetDocumentsById(id);
	if (list != null && list.AreItemsAvailable)
	{
		foreach (ListItem item in list)
		{
			SharePointDocument file = ListItemToSharePointDocument(item);
			files.Add(file);
		}
	}

	var response = Request.CreateResponse(HttpStatusCode.OK);
	response.Content = new StringContent(JsonConvert.SerializeObject(files), Encoding.UTF8, "application/json");
	return response;
}

The function starts by Retrieving the Authorization Credentials. This is either passed by the Web Resource from CRM as an encoded string as part of the request, or in our case stored in the application setting. The function checks if the Request.Authorization.Header contains a value. If it does it retrieves the string from the Authorization header, or if not it creates the Authorization string from the Application Settings Username and Password.

private string DecodeAuthorizationString()
{
	string userPass = string.Empty;
	if (Request.Headers.Authorization == null)
	{
		// throw HttpResponseHelper.GetUnauthorizedResponseException("Auth Header is null!");
		string emailAddress = ConfigurationManager.AppSettings["Email"].ToString();
		string password = ConfigurationManager.AppSettings["Password"].ToString();
		userPass = string.Format("{0}:{1}", emailAddress, password);
	}
	else
	{
		var authHeader = Request.Headers.Authorization;
		if (authHeader.Scheme.ToLower() != Constants.AUTH_HEADER.BASIC)
		{
			throw HttpResponseHelper.GetUnauthorizedResponseException("Auth Header is not using BASIC scheme!");
		}
		var encodedUserPass = authHeader.Parameter;
		userPass = Encoding.UTF8.GetString(Convert.FromBase64String(encodedUserPass));
	}
	return userPass;
}

We then call the Set SharePoint Credentials function passing the Authorization string. This is using a Helper Class that handles with connectivity to SharePoint and executing SharePoint Client Commands against SharePoint.

public static void SetSharePointCredentials(string authorization)
{
	string[] authCredentials = authorization.Split(':');
	ServiceUserName = authCredentials[0].ToString();
	ServicePassword = authCredentials[1].ToString();
}

The GetDocumentsById connects to SharePoint (if not already connected), creates a CAML query with a where clause to search by the Master Id and returns a ListItemCollection.

public static ListItemCollection GetDocumentsById(string masterId)
{
	ClientContext ctx = ConnectToSharePoint();

	List spList = ctx.Web.Lists.GetByTitle("Documents");
	ctx.Load(spList);
	ctx.ExecuteQuery();

	if (spList != null && spList.ItemCount > 0)
	{
		string whereClause =  String.Format(@"<Where>
			<Eq><FieldRef Name='MasterId' /><Value Type='Text'>{0}</Value></Eq>
			</Where> ", masterId);

		CamlQuery camlQuery = new CamlQuery();
		camlQuery.ViewXml = String.Format(
		   @"<View Scope='RecursiveAll'>
			<Query> 
				{0}
			</Query> 
			 <ViewFields>
				<FieldRef Name='FileLeafRef' />
				<FieldRef Name='Title' />
				<FieldRef Name='MasterId' />
				<FieldRef Name='MasterNumber' />
				<FieldRef Name='MasterName' />
			<FieldRef Name='DocumentType' />
				<FieldRef Name='Created' />
			</ViewFields> 
	</View>", whereClause);

		ListItemCollection listItems = spList.GetItems(camlQuery);
		ctx.Load(listItems);
		ctx.ExecuteQuery();

		return listItems;
	}
	else
		return null;

}

We then loop through the items of the collection, and convert each ListItem to a SharePointDocument. SharePointDocument is a Model class that contains the fields that are returned from SharePoint, and will be returned to the web resource as a Json string. The function below shows the ListItemToSharePointDocument function which handles the conversion.

private SharePointDocument ListItemToSharePointDocument(ListItem item)
{
	SharePointDocument file = new SharePointDocument();
	file.FileId = (item["UniqueId"].ToString().ToGuid());
	file.MasterId = item["MasterId"] != null ? item["MasterId"].ToString() : "";
	file.MasterNumber = item["MasterNumber"] != null ? item["MasterNumber"].ToString() : "";
	file.DocumentType = FieldLookupValueToLookupItem(item["DocumentType"]);
	file.MasterName = item["MasterName"] != null ? item["MasterName"].ToString() : "";
	file.FileName = item["FileLeafRef"].ToString();
	file.FilePath = item["FileRef"].ToString();

	return file;
}

Finally, we create the response passing a Status of OK (regardless whether or not files were returned), and serialize the files object as a Json string and return the response.

The list of functions that are included as part of the Api are:

  • GetByMasterId
  • GetByMasterNumber
  • GetByAlternateField
  • DownloadFile
  • UploadDocument
  • SetFileAttributes
  • DeleteFile
  • GetRootFolders
  • GetFolder
  • CreateRootFolder

The next and final articles in this blog series will cover the creation of the web resource.

 

 

The post Dynamics 365 and SharePoint Online Integration – Web Api Development appeared first on Aric Levin's Digital Transformation Blog.

]]>
Dynamics 365 and SharePoint Online Integration – Azure Configuration https://aric.isite.dev/dynamics/post/dynamics-365-sharepoint-online-integration-azure/ Mon, 26 Feb 2018 00:09:00 +0000 https://aric.isite.dev/index.php/2018/02/26/dynamics-365-and-sharepoint-online-integration-azure-configuration/ The next part of this solution is to configure Microsoft Azure. If you do not have an Azure account, you can create a Trial account of Pay as you go account. If you are a partner or have a BizSpark subscription you get a certain amount of credits per month, which should be more than enough for the type of implementation that needs to be done using Azure.

The post Dynamics 365 and SharePoint Online Integration – Azure Configuration appeared first on Aric Levin's Digital Transformation Blog.

]]>
The next part of this solution is to configure Microsoft Azure. If you do not have an Azure account, you can create a Trial account of Pay as you go account. If you are a partner or have a BizSpark subscription you get a certain amount of credits per month, which should be more than enough for the type of implementation that needs to be done using Azure.

The first thing that we need to do is create an Application, so that we can register the Client Id for the new Application. In order to create an application. In your left hand navigation click on Azure Active Directory, and select App Registrations from the list of options. Click on New application registration button shown below.

Azure App Registration

In the Create window, enter a Name for the application, the Application Type (Native), and the Redirect Uri (not really used in this case), and then click on the Create button. Once the application is registered, you will be able to see its properties in the Registered App window. You will need the Application Id to store in the Client Id window. Next, we will need to provide the application permissions to the SharePoint server. Click on the Settings button in the Registered app Pane. This will open the Settings window.

Azure App Registration

From there click on the Required permissions under API ACCESS section. By default you will only have the Windows Azure Active Directory permissions. Click on the Add button to add additional permissions. We will need to add Office 365 SharePoint Online (Microsoft.SharePoint) permissions. Select Office 365 SharePoint Online, and check all the required permissions. At the least, you will need the following permissions:

Azure App Registration Permissions

Now that we have registered the App in Azure, we need to create an App Service with Azure. The type of App that we need to create is an Api app, which allow the connectivity between Azure and SharePoint.

In the Microsoft Azure navigation click on App Services. This will display the AppService navigation as shown in the following image. Click on the Add button.

Add New App

In the Web Apps section shown below, click on the More button in order to see the selection for API App.

Select Api

Click on the API App link, and then click on the Create button.

Select API App

This will display the new API App window. Enter the name of the App, Subscription, Resource Group (either Add New or use an existing one) and the App Service Plan/Location. Click on Create button to finalize the Creation of the App. Once the app is created we will need to add some Application Settings to it as well as set up Cross-Origin Resource Sharing (CORS), which will allow Dynamics 365 code to execute the API functions.

In the Application Settings window, we will enter the following settings (as shown in the image and table below):

App Settings

Application Setting Application Setting Description
MAX_ITEMS_PER_FOLDER Enter the maximum number of files that can be entered in a particular SharePoint folder. This should be no more than 5000
SITE_URL The root url of your SharePoint environment. This will be in the format of: https://SPROOT.sharepoint.com
WEB_FULL_URL The url of the SharePoint document library. This will be in the format of https://SPROOT/sharepoint.com/sites/doccenter
ClientId The client id (or application id) that is generated by Azure for this application. See previous instructions
RedirectUrl You can set this as the Url of your CRM environment
Email An email account with access to SharePoint. This should most likely be set as a service account and not an individual user account
Password The password of the email account specified above. If you encrypt the password, you will have to modify the code that authenticates against SharePoint to decrypt the password

Finally, you will have to set up CORS, so that only CRM has access to this API. The screenshot below shows you the configuration of CORS. All that is required is the Url of the CORS

CORS Setup

In the next article of the series, we will go over the Web Api, and uploading it to Azure.

The post Dynamics 365 and SharePoint Online Integration – Azure Configuration appeared first on Aric Levin's Digital Transformation Blog.

]]>
Dynamics 365 and SharePoint Online Integration – SharePoint https://aric.isite.dev/dynamics/post/dynamics-365-sharepoint-online-integration-sp/ Sun, 25 Feb 2018 21:25:00 +0000 https://aric.isite.dev/index.php/2018/02/25/dynamics-365-and-sharepoint-online-integration-sharepoint/ The easiest part of this solution is to configure SharePoint. There is no custom development involved, but just the creation of the document library, the folders, custom lists and the attributes that we want to use for the solution. We will need to start with the creation of the custom lists as they will be used for the creation of the lookup attributes.

The post Dynamics 365 and SharePoint Online Integration – SharePoint appeared first on Aric Levin's Digital Transformation Blog.

]]>
The easiest part of this solution is to configure SharePoint. There is no custom development involved, but just the creation of the document library, the folders, custom lists and the attributes that we want to use for the solution. We will need to start with the creation of the custom lists as they will be used for the creation of the lookup attributes.

For our particular scenario, we create a Document Library called Document Center with a relative url of doccenter. In the root folder of the document center we created the following attributes (in addition to the default attributes):

MasterId, MasterNumber, MasterName, DocumentType

SharePoint Attributes

We also created 3 folders for ACCOUNTS, CASES and CONTACTS, though for the purpose of this series, we will only demonstrate the ACCOUNTS subgrid.

We also create a list called DocumentTypes which will be used by the DocumentType attribute to specify the type of document this is. No special configuration was done to the Document Type list, as we are using only the Title field.

We used the Master Id, Master Number and Master Name fields so that they can be used across the board for the various entities, however you can add additional fields or change them based on your requirements.

In the next section we will review how to configure the Microsoft Azure web site in order to have Azure connect to SharePoint.

The post Dynamics 365 and SharePoint Online Integration – SharePoint appeared first on Aric Levin's Digital Transformation Blog.

]]>
Dynamics 365 and SharePoint Online Integration – Overview https://aric.isite.dev/dynamics/post/dynamics-365-sharepoint-online-integration-overview/ Sun, 25 Feb 2018 21:05:00 +0000 https://aric.isite.dev/index.php/2018/02/25/dynamics-365-and-sharepoint-online-integration-overview/ Over the past few years we have encountered multiple scenarios where the Out of the Box SharePoint Integration component, did not fulfill the requirements of our clients using Dynamics 365 and SharePoint. Some of these had to do with capturing additional attributes in SharePoint, and sharing similar data across different entities in SharePoint.

The post Dynamics 365 and SharePoint Online Integration – Overview appeared first on Aric Levin's Digital Transformation Blog.

]]>
Over the past few years we have encountered multiple scenarios where the Out of the Box SharePoint Integration component, did not fulfill the requirements of our clients using Dynamics 365 and SharePoint. Some of these had to do with capturing additional attributes in SharePoint, and sharing similar data across different entities in SharePoint.

We ended up developing a solution that will solve some of this problems by using Azure API and the SharePoint Client Tools (can also be done with SharePoint API of course), and developing a custom web resource that will call the Azure API functions provide the ability to upload files to SharePoint as well as download files from SharePoint.

The image below shows the end result of the SharePoint Grid inside of a CRM entity.

SharePoint Grid

I will provide a separate post for each of the following portions of the application is the next week (or so), as well as post a copy of the different portions of the Source Code on github.

This series will include the following articles:

The post Dynamics 365 and SharePoint Online Integration – Overview appeared first on Aric Levin's Digital Transformation Blog.

]]>