How to – Stop synchronization of Task / Appointment between Dynamics 365 and Outlook


In the earlier posts we saw how synchronization works for different activities type and how to work with user as well as system filters.

In this post, we will how to use the wonderful Sync Filter Manager (XrmToolBox Plugin) for managing the outlook filters.

Suppose we don’t want Tasks to be synced for some of the users.

Here we already have a custom user filter (Task- Created on is null) defined for one of the users, specifying the condition which will always be false.

We have also disabled the default filter on tasks – My Tasks for that user.

For that particular user, now we do not see any tasks getting synced.

Now to apply the same setting to the others users, we can use the wonderful Sync Filter Manager – XrmToolBox plugin.

To know more about the tool –

http://mscrmtools.blogspot.com/2013/12/introducing-new-tool-sync-filter-manager.html

https://www.slideshare.net/jukkan/control-outlook-synchronization-settings-for-dynamics-crm-users

Navigate to the Users tab, search for the user whose setting we want to apply to other users, and select it.

Here we have selected the source user record

Click on Apply selected user synchronization filer to user(s) button.

For Question Dialog Box – “Are you sure want to apply the selected user synchronization filters to other users ?” – select Yes

For now, we have selected only User 2. We can select multiple users or select / unselect all the users.

It will remove the default / or existing filters from users. User 2 in our case.

And will add the filters from the selected user to it.

After some time, we can see the filters updated for User 2, with the Task – Created on is null filter added.

We can also verify it from the User Synchronization Filters tab, where we can load the synchronization filters for all the users.

As a last step we just need to deactivate/delete the default My Tasks filter for User 2 also(or all the other users for who we want to disable task sync) and we are done.

Hope it helps..

Advertisements

How to – Define System Filters for Synchronization using SavedQuery in Dynamics 365 / CRM


We covered a few Synchronization topics in the last few blogs, here we will look at defining system filters to manage which records could be synced.

How to – Synchronize Appointments between Dynamics 365 and Outlook using Server-Side Synchronization

How are tasks, letters, fax, phone call synchronized between Dynamics 365 and Outlook

We can see few default User Filters already defined that syncs records owned by the current user.

Users can create new filters, edit the existing filters, delete, activate, deactivate and reset the filters.

These filters like personal filters applied to that particular user only.

The same can also be accessed from Personalization Settings

Personal Options > Synchronization tab

Similar to User Filters we can define System Filters that apply to the entire organization or all the users.

As we can see there are no options (no new button) to create new System Filters from the user interface. The only way we can create them is through SDK.

Suppose we don’t want any tasks to be synced.

For this, we can create a filter like “sync only those tasks where created on doesn’t have value” which will always evaluate to false.

On executing the below code

We can see the system filter created successfully.

Hope it helps..

Entity savedQuery = new Entity("savedquery");
                savedQuery.Attributes["name"] = "System Filter for Task";
                savedQuery.Attributes["description"] = "To restrict sync of tasks";            
                savedQuery.Attributes["isquickfindquery"] = false;

                // saved query is of type outlook fiter
                savedQuery.Attributes["querytype"] = SavedQueryQueryType.OutlookFilters;
                
                savedQuery.Attributes["returnedtypecode"] = "task";

                // sync only those tasks which have created on as null
                // this is to restrict task sync

                savedQuery.Attributes["fetchxml"] = 
                    @"<fetch>" +
                     "<entity name='task'>"+
                     "<attribute name='activityid'/>" +
                     "<filter>" +
                     "<condition attribute='createdon' operator='null'/>" +
                     "</filter>" +
                     "</entity>" +
                     "</fetch>";

                var response= svc.Create(savedQuery);
Advertisements

How to – Upload files to File Column / Attribute using SSIS – KingswaySoft (Dynamics 365/ CRM)


Let us take a simple example to understand how we can upload files to the file column through SSIS Package + KingswaySoft’s Integration Toolkit.

Here we have a File Column defined for the Contact Entity.

This is what our final package looks like –

Our SSIS package will pick up the contact’s email, file path, and file name from the CSV file as the source using the Premium Flat File Source component.

The premium derived component adds a new column that reads / stores the binary content of the file specified in excel.

Finally, in CDS Destination we are doing Upsert on contact entity based on the email id field specified in the source excel file.

The mapping –

On running the package, we can see the file uploaded to the corresponding contact records.

To extract attachment from notes-https://nishantrana.me/2021/02/10/extracting-attachments-from-notes-in-dynamics-365-dataverse/

To download files using Download Block Request –https://nishantrana.me/2022/03/14/how-to-download-file-from-file-column-using-initializefileblocksdownload-and-downloadblock-request-dynamics-365-crm-dataverse/

To upload files using Upload Block Request –https://nishantrana.me/2022/03/15/how-to-upload-file-to-file-column-using-initializefileblocksupload-and-uploadblock-request-dynamics-365-crm/

Understand File and Image Data Type –https://nishantrana.me/2021/10/01/using-file-and-image-data-type-in-dataverse-dynamics-365/

Try out the wonderful, feature-rich, and powerful SSIS Integration Toolkit for Dynamics 365 by KingswaySoft –https://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365/download

Check other articles on SSIS plus CRM – https://nishantrana.me/2018/11/26/ssis-and-microsoft-dynamics-365/

Hope it helps..

Advertisements

How to – Download files from File Column / Attribute using SSIS – KingswaySoft (Dynamics 365/ CRM)


Let us take a simple example to understand how we can download files from the file column using SSIS Package + KingswaySoft’s Integration Toolkit.

Here we have a File Column defined for Contact Entity.

Our SSIS package will run on all the contact records and will extract the file from the records to one of the folders in the local machine.

This is what our package’s data flow looks like.

It has just 2 components CDS Source and Premium Derived Column.

CDS Source is connected to the Contact entity.

For Columns, we have selected our file column fields.

Next, we have next added a Primary Derived Column component.

We have used the WriteBinaryComponent function to write the binary content (new_myfile_binarycontent field) to a file.

WriteBinaryContent(“D:\\MyDownloadedFile\\”+[new_myfile_name], new_myfile_binarycontent])

On running the package successfully, we can see the files downloaded at the folder specified.

The result – as we just had 2 contact records out of 106 having file uploaded to it we can see those 2 filed downloaded.

Hope it helps..

Advertisements

How to – Upload File to File Column using InitializeFileBlocksUpload and UploadBlock Request (Dynamics 365/ CRM)


Sharing a sample code, we can use to upload a file to the File Column

Also read –

https://nishantrana.me/2021/10/01/using-file-and-image-data-type-in-dataverse-dynamics-365/

File Attribute

https://nishantrana.me/2022/03/14/how-to-download-file-from-file-column-using-initializefileblocksdownload-and-downloadblock-request-dynamics-365-crm-dataverse/

Here we would upload the below file to one of the contact records.

For file size more than 4 MB we need to implement chunking and combine the data before committing.

uploadimg

On calling the method –

We can see the file uploaded to the contact record.

The restriction of using chunked upload for files greater than 16 MB has been removed, see the below code for full file upload. The chunking APIs are still kept for backward compatibility.

Example – .NET C# code for full file upload. (recommended way of uploading)

Hope it helps..

  private static void UploadFile(CrmServiceClient svc, string entityName, Guid recordGuid,
           string fileAttributeName, string filePath, string fileName)
        {
            // get the file content in byte array
            var fileContentByteArray = File.ReadAllBytes(filePath);

            var initializeFileBlocksUploadRequest = new InitializeFileBlocksUploadRequest()
            {
                Target = new EntityReference(entityName, recordGuid),
                FileAttributeName = fileAttributeName,
                FileName = fileName
            };

            var initializeFileBlocksUploadResponse = (InitializeFileBlocksUploadResponse)
                svc.Execute(initializeFileBlocksUploadRequest);

            // to store different block id in case of chunking           
            var lstBlock = new List<string>();         

            // 4194304 = 4 MB
            for (int i = 0; i < fileContentByteArray.Length / 4194304  ; i++)
            {
                var blockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()));
                lstBlock.Add(blockId);
                
                var uploadBlockRequest = new UploadBlockRequest()
                {
                    BlockId = blockId,
                    BlockData = fileContentByteArray.Skip(i * 4194304).Take(4194304).ToArray(),
                    FileContinuationToken = initializeFileBlocksUploadResponse.FileContinuationToken
                };

                var uploadBlockResponse = (UploadBlockResponse)svc.Execute(uploadBlockRequest);
            }

            var commitFileBlocksUploadRequest = new CommitFileBlocksUploadRequest
            {
                FileContinuationToken = initializeFileBlocksUploadResponse.FileContinuationToken,
                FileName = fileName,
                MimeType = System.Web.MimeMapping.GetMimeMapping(fileName),
                BlockList = lstBlock.ToArray()

            };

            var commitFileBlocksUploadResponse = (CommitFileBlocksUploadResponse)svc.Execute(commitFileBlocksUploadRequest);
        }
Advertisements

How to – Download File from File Column using InitializeFileBlocksDownload and DownloadBlock Request (Dynamics 365/ CRM / Dataverse)


Sharing a sample code which we can use to download the file from the File Column

Also read –

https://nishantrana.me/2021/10/01/using-file-and-image-data-type-in-dataverse-dynamics-365/

File Attribute

Here we would download the below file uploaded to one of the contact records.

The sample code –

On calling the method –

We can see the file downloaded at the location specified

Here the file transfers are limited to a maximum of 16 MB in a single call. In case of more than 16 MB, we need to divide the data into 4 MB or smaller chunks, combine or join the downloaded data to form the complete file.

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/file-attributes#example-net-c-code-for-download-with-chunking

Get more details – Retrieve File Data

*interestingly enough we didn't get any error while trying to download files with size more than 16 GB by using the DownloadBlockRequest

Hope it helps..

private static void DownloadFile(CrmServiceClient svc, string *interestingly enough we didn't get any error while trying to download files with size entityName, Guid recordGuid, 
            string fileAttributeName, string filePath)
        {
            var initializeFileBlocksDownloadRequest = new InitializeFileBlocksDownloadRequest
            {
                Target = new EntityReference(entityName, recordGuid),
                FileAttributeName = fileAttributeName
            };

            var initializeFileBlocksDownloadResponse = (InitializeFileBlocksDownloadResponse)
                svc.Execute(initializeFileBlocksDownloadRequest);

            DownloadBlockRequest downloadBlockRequest = new DownloadBlockRequest
            {
                FileContinuationToken = initializeFileBlocksDownloadResponse.FileContinuationToken
            };

            var downloadBlockResponse = (DownloadBlockResponse)svc.Execute(downloadBlockRequest);

            // Creates a new file, writes the specified byte array to the file,
            // and then closes the file. If the target file already exists, it is overwritten.

            File.WriteAllBytes(filePath + 
                initializeFileBlocksDownloadResponse.FileName, 
                downloadBlockResponse.Data);

        }
Advertisements