Using DataSourceInfo and RecordInfo function for checking permissions for a Dataverse table or record in Canvas App


DataSourceInfo function can be used to check the Table / Entity level permission.

We can check for Create, Read, Edit, and Delete Permission and can disable, hide and show the corresponding create, edit and delete buttons for the users.

  • DataSourceInfo.CreatePermission
  • DataSourceInfo. DeletePermission
  • DataSourceInfo. EditPermission
  • DataSourceInfo. ReadPermission

DataSourceInfo function can also be used to obtain information about a particular column of the data source like Display Name, Max Length, Max Value, Min Length, Required.

https://www.inogic.com/blog/2020/11/how-to-use-datasourceinfo-in-canvas-app/

  • DataSourceInfo.DisplayName
  • DataSourceInfo.MaxLength
  • DataSourceInfo.MaxValue
  • DataSourceInfo.MinValue
  • DataSourceInfo.Required

     

Similarly, the RecordInfo function can be used to get the information about the record of a Dataverse data source.

We can check for the Read, Edit, and Delete Permission.

  • RecordInfo. ReadPermission
  • RecordInfo. EditPermission
  • RecordInfo.DeletePermission

Hide Show control based on Security Role in Canvas App

Here for our sample Canvas App we have a button and a Gallery  having Data source as Cases

1 

Visible    

Button

If(DataSourceInfo(Cases,DataSourceInfo.ReadPermission), true, false)

2 

Visible   

Edit

If(RecordInfo(Gallery1.Selected, RecordInfo.EditPermission),true, false)

3 

Visible    

Delete

If(RecordInfo(Gallery1.Selected, RecordInfo.DeletePermission),true, false)

Now to test it, we have assigned the below custom security role/rights to another user – Test User 1 (along with Basic User security role)

i.e. Read, Write and Delete permission at the User Level on Case.

We have also shared the Average order shipment time record with Test User 1 assigning him the Write Permission.

Now when Test User 1 will open the Canvas App, the first button will be visible as he has the Read permission on the Case table.

In the gallery only the one record shared will be visible along with the Edit button on the same.

Let us just share one more case record with only Read permission to Test User 1.

We can see the record displayed for Test User 1.

It shows the Edit button for the new record, although we shared the record with the Read permission.

We have the following formula for the Edit button’s OnSelect

Patch(Cases, LookUp(Cases,’Case Number’ = lblCaseNumber.Text), {‘Case Title’:”Sample Title”})

So clicking on Edit for the new record shared ‘Complete overhaul required‘ gives the below Permission error

Now pressing the same edit button for the ‘Average order shipment time’ record will update the record (set title as Sample Title) as it was shared with Write permission with Test User 1.

Get all the details here –

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datasourceinfo

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-recordinfo

Hope it helps..

Advertisements

Updated Solution Explorer (Preview) experience in Dynamics 365


Microsoft recently announced the public preview of the new solution explorer which will eventually be the default experience going forward.

Earlier we could access it by visiting the – https://make.preview.powerapps.com/

In the new experience, we can Enable / Disable the new Solution Explorer by toggling the Solution preview on

The is how the existing solution experience looks like – here we have opened the Default solution.

With the new experience, the solution selected opens up and takes the whole page, with the new left navigation added.

Also, it adds a new Tree style of navigation for Objects.

+New button experience has been updated.

Left is the old experience listing each component and new experience in the right with the options grouped.

The overview section gives the details of the solution like display name, name, package type, etc. with the option to edit the details.

  • The option to run the Solution Checker.
  • Manage Search Index.
  • Recent activities performed.

The history page gives the details of the operations performed on the solution.

If we still need we can switch to classic

Performance improvements through parallel loading (Tree View) and caching (Solution objects, authentication while switching to classic, etc.

Get all the details here

https://powerapps.microsoft.com/en-us/blog/managing-solutions-has-a-new-look-public-preview/

Hope it helps..

Advertisements

Using File and Image Data Type in Dataverse (Dynamics 365)


File Data Type was introduced somewhere around late 2019. At that time, it was only available for Canvas App and Power Automate / Flow, and with subsequent updates, it was then added for Model Driven App as well.

https://powerapps.microsoft.com/en-us/blog/introducing-improvements-to-data-storage-in-common-data-services/

The File Data type while creating the column à

By default, the file size is 32,768 KB.

  • Min – 1 KB
  • Maximum – 131072 KB

Let us keep it as 2000 KB and save it.

Here we have added the field in the form.

We need to save the record before the field is enabled.

On trying to upload a file more than 2000 KB size, the max size, we specified while creating the column, will give the below error.

“The upload failed for File Column 1. Please try again or contact your admin.”

The Maximum file size property cannot be updated after the column is created.

Similarly, we have the Image data type.

The default size is 10240 KB.

  • Min – 1 KB
  • Max – 30720 KB

If the image size is more than specified, we will get the below error message

The upload failed for Image Column 2. Please try again or contact your admin.

Below we have added a new file type column named File Column 2 with a maximum size of 100 MB.

With 2020 Release Wave 2, there is no need to specify file chunking while uploading a file of 16 MB or more, by dividing file data blocks of 4 MB or less through API.

https://docs.microsoft.com/en-gb/power-platform-release-plan/2020wave2/data-platform/improvements-microsoft-dataverse-file-image-upload-download

Earlier à

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/file-attributes#retrieve-file-data

Below is the sample code we have used to upload a file of size 86 MB.

The file uploaded à

Now let us look at downloading part.

The URL that can be used are

Byte Array formatà
https://%5Borganization%5D/api/data/v9.1/entitySetName(entityID)/fileTypeAttributeName/$value?size=full

Base64 String formatà

https://[organization]/api/data/v9.1/entitySetName(entityID)/fileTypeAttributeName/?size=full

Let us try the URL in the browser for both below File column 1 and 2.

https://pmaurya105.crm.dynamics.com/api/data/v9.1/crad3_sampletables(2d15b66a-a8b4-eb11-8236-000d3a1d5bf4)/crad3_filecolumn1/$value?size=full

It downloads the file for File Column 1à

In case of File Column 2, we get the below error message as its size exceeds 16 MB à

{“error”:{“code”:”0x80090001″,”message”:”Maximum file size supported for download is [16] MB. File of [84 MB] size may only be downloaded using staged chunk download.”}}

Base 64 Format ->

Below is the sample C# code to download the file if the size is less than 16 MB

If it is more than 16 MB we will get the below error à Request Entity Too Large

For Image Data Type, for uploading the full image > 16 MB (without dividing into a smaller chunk of less than 4 MB), we can use the below source code. It is the same as for the file data type.

For download, we can download either the thumbnail or full image (<= 16 MB) using the same source code used for file download.

For thumbnail –

GET [Organization URI]/api/data/v9.1/entity(recordGuid)/myentityimage/$value

For full image –

GET [Organization URI]/api/data/v9.1/entity(recordGuid)/myentityimage/$value?size=full

For more than 16 MB we need to use chunking.

Get all the details below à

https://jukkaniiranen.com/2019/12/why-would-you-store-images-and-files-in-cds/

https://debajmecrm.com/new-data-type-filein-cds-all-you-may-need-to-know-about-it/

https://debajmecrm.com/retrieve-contents-of-file-data-type-field-in-dynamics-365-cds-using-javascript-client-code/

Hope it helps..

Advertisements

Canvas App – Quick Reference


Recently we were working on Canvas Apps so thought of listing down some of the key points for quick reference

  • Use Items property for defining values for Drop Down and Combo Box.

Items = [“Branch”,”Country”]


  • Use DefaultSelectedItems for Setting Default values for Combo Box.

DefaultSelectedItems = [“Branch”]

  • To disable multiple selections for Combo Box set SelectMutiple as false

SelectMultiple = false


  • Change Data Source of Gallery based on Combo Box selected value

Items = If(ComboBox1.Selected.Value = “Branch”, Branches, Countries)


  • Filter Gallery’s data based on Text Box (string search)

Items = If(ComboBox1.Selected.Value = “Branch”,Filter(Branches,searchInput.Text in cre9d_value ||searchInput.Text in cre9d_name), Filter(Countries,searchInput.Text in cre9d_value ||searchInput.Text in cre9d_name))

Filter à

Search à

  • Unlock the Data Card field within the form to make changes to its properties

  • Use Navigate to move to a different Screen on OnSelect of Button

Navigate(Screen2, ScreenTransition.Fade)

  • The first item of the Gallery acts as a template

  • Use TemplateFill property to highlight the selected item in the Gallery.

TemplateFill = If(ThisItem.IsSelected,RGBA(233,150,150,10))

  • Use Sort to sort the Data Source for Items property

Items = Sort(Requests,’Created On’,Descending)

  • Fetch User’s Security Role and hide and show control based on it.

If(LookUp([@’Security Roles’], Name = “Maker”, Role) in Concat(LookUp([@Users], ‘Primary Email’ = User().Email).’Security Roles (systemuserroles_association)’, Role & “;”), true, false)

  • Submit, Reset, and New Form on saving a record on OnSelect of Button

SubmitForm(frmRequest);

ResetForm(frmRequest);

NewForm(frmRequest);

  • DataField is the most important property of the DataCard, which binds the control to the field in the Data Source.

The default value of the DataCard.

  • ThisItem is how we interact with the current record.

  • On SubmitForm – the form control reads the value of DataField property of all the cards to find the field to change and the value of each card from the Update property.

  • Clear Button and Enable Spell Check option for Text Input

checks for the spelling as well provide the option to clear the text box as shown below.

Update / Set a Contextual Variable (referenced on the screen where they are created) 

UpdateContext({varCount: 1, varActive: true, varName: User().FullName})

Set a global variable (available across the app

Set(varCount, 1);Set(varActive, true);Set(varName, User().FullName)

  • With UpdateContext we can declare more than one variable at a time, which is not possible with global variable.
  • Use GUID function à

To generate a new GUID use  GUID()

To convert a string to GUID(“0f8fad5b-d9cb-469f-a165-70867728950e”)

  • To set a variable null – Set(myNullVar, Blank())
  • GroupBy  function – returns a table with records grouped together based on the values in one or more columns.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-groupby

GroupByTableColumnName1 [, ColumnName2, … ], GroupColumnName )

  • ForAll function – to evaluate a formula against all records of a Table

ForAll(TableFormula)

  • Table – Required. Table to be acted upon.
  • Formula – Required. The formula to evaluate for all records of the Table.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-forall

  • Component – Reusable control

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-component

  • Pass parameter 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-param#param

  • Patch gives more control than SubmitForm

https://sharepains.com/2020/06/19/patch-vs-submitform-vs-update-power-apps/

  • Delegable data sources – Dataverse, SharePoint, SQL Server

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

https://docs.microsoft.com/en-us/connectors/commondataservice/#power-apps-delegable-functions-and-operations-for-dataverse

  • Get the response from Power Automate

  • App OnStart Property

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/object-app#onstart-property

  • Using Excel as Static Data for the app.

http://powerappsguide.com/blog/post/code-how-to-define-a-read-only-table-of-static-data

  • Connection.Connected (Offline) – to check if app is connected to network or not.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/signals#connection

  • Concurrent Function to evaluate multiple formulas at the same time.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-concurrent

  • IfError for Error handling

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-iferror#iferror

  • AppChecker – for checking the canvas app for accessibility.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/accessibility-checker

Hope it helps ..

Advertisements

Delete the current (active) partition in Audit – Dynamics 365


We recently exceeded log storage capacity for our Power Platform environment

We can check the same at Resources >> Capacity inside the Power Platform admin center.

One of the sandbox environments had the most Log Usage

https://docs.microsoft.com/en-gb/power-platform/admin/legacy-capacity-storage#capacity-page-details

We deleted the plugin trace logs and all the audit partitions (except the active/current one, which the system doesn’t allow)

If we try deleting the current active partition, we will get the below error –

Microsoft.Crm.CrmException: You cannot delete audit data in the partitions that are currently in use, or delete the partitions that are created for storing future audit data.

The partitions are created on quarterly basis each year –

1 Jan – April, 1 April – July, 1 July – October, 1 Oct – January

Even after deleting the plugin trace logs and the partitions, we didn’t see any change in the storage capacity usage. So we raised a Microsoft Support Ticket and were informed by the team that they can delete the active partition for us, and it could take around 3 days. As that was a sandbox environment and we had no use of Audit data we went ahead and the Support Team deleted the active partition for us. (Also there was some issue in our data center with regards to the recalculation of the storage and it took few more days for that change to reflect inside the Capacity page of Power Platform Admin Center).

This way we were able to reclaim some of the log storage.

So basically we just need to raise Microsoft Support Ticket and request the same.

More on Audit

Also check the new process for deleting audit logs –

https://docs.microsoft.com/en-gb/power-platform/admin/free-storage-space#method-10-delete-audit-logs—new-process

Select audit logs to delete.

Hope it helps..

Tracking email and automatic record creation – Personal Options in Dynamics 365


Let us have a look at the different options provided in the Email Tab for Tracking and Automatic creation of records.

Select Personalization Settings in the Settings icon within the app.

Select Email tab within Set Personal Options Dialog box.

Select the email messages to track in Microsoft Dynamics 365 option has the following values

Email messages in response to Dynamics 365
email is the default option.

Let us start with the All email messages option.

  • All email messages – In the case of all email messages, all email messages will be tracked in Dynamics 365, including the junk mail.

Here we have sent a test email to the CRM User with Track All email messages selected

The CRM user has his mailbox already configured.

Sample mail sent to the CRM user from the personal Hotmail account.

Inside Outlook Office, we can see the same mail received and marked as Tracked to Dynamics 365.

And an email activity created inside CRM.

We can see the existing contact record having the matching email id being set as from for the email.

If no contact record is found with the same email id, then a new contact record will be created for the tracked email, if the below setting “automatically create record” is enabled.

Here I am now sending an email to the CRM user through my Gmail id. (This email id doesn’t exist in CRM for any records)

We can see the mail tracked, and the email activity created along with the new contact record.

Let us just disable create record option and also delete the existing contact records (both Hotmail and Gmail) with matching email id, so that no match is found.

Let us again send an email from the Hotmail account to the CRM user

This time in the email activity created, we see the email id marked as red as there were no matching records in CRM.

Also as we had disabled contact creation so no contact record was created.

  • What if we enable Lead Creation instead?

Remember we still do not have any existing matching contacts in CRM as we have deleted them.

Let us sent a test mail and check.

The email activity inside CRM will have the From part set as the lead record created as part of tracking.

Below is the lead record created with associated email

  • What if we have both lead and contact records with the matching email id, to which record will the tracked email be associated?

The answer is the contact record.

  • Now let us look at the other tracking option – Email messages from Dynamics 365 Leads, Contacts, and Accounts – In this case only if the email is originated from the user having an existing lead, contact, or account record will be tracked.

  • Let us send an email from an account that doesn’t have any lead, contact, or account record created inside CRM.

And also email from an account that has both lead and contact records.

After a couple of minutes, we can see the mail from the account having lead and contact records being tracked and the other email from an account that doesn’t have any matching records not being tracked.

The email activity is associated with the contact record as expected.

  • Now let us send the mail from an account with matching lead and contact, this time we have disabled the matching contact record.

So now the system has only a matching lead record.

We have disabled the matching contact record.

Result – We can see the email activity associated with the lead in this case as the contact was disabled.

  • Now let us disable and both matching lead and contact see the result.

And create one more custom entity record with email enabled having matching email id.

In this case, the email activity is associated with an active custom entity record having the matching email id


Now let us try the same by disabling this custom record as well i.e. now we have all the matching records lead, contact, and the custom entity one disabled.

Result – As no matching record was found it creates it against an email and highlights it in red.

It is tracked the email even though the record were inactive.

Now let us delete that inactive contact record and send the same mail from the same account. We have the create contact option enabled right now.

Result – The mail was tracked but no contact record was created.

  • Now let us delete the matching inactive lead record from CRM, and keep the matching inactive custom entity record as it is.

Result – Now as we do not have any lead or contact record, the email as expected is not tracked as we have opted for tracking – Email messages from leads, contact, and accounts.


  • Let us change the tracking option to Email messages from Dynamics 365 records that are email enabled – In this case, all email messages will be tracked for those entities having email-enabled (including custom entities)


We can see the email tracked even though the custom matching record is inactive.

  • Now let us set the tracking option as Email messages in response to Dynamics 365 email


This will track replies or forwards of email messages that have already been tracked.

Let us send a new mail, we only have an inactive matching custom entity record in CRM right now.

As expected the email is not traced as it is a new email, not a response.

  • Let us send another email, this time we have created a matching contact record in CRM.

As expected the emails are not tracked as they are not the responses.

  • Now let us respond to an existing tracked email.

Reply Sent From Outlook :

Reply From within CRM :

We can see it tracked in CRM.

  • And finally the last option No email messages is self-explanatory

In a nutshell

Tracking  
All Email Messages Email tracked, email activity created.

 

If an existing contact record is found, it is associated.

If no contact record is found, it will be created if Create contact record option is enabled. Here if for Create Option we have selected Lead then lead will be created instead.

If no existing record is found and create contact is disabled, then it is associated with an unknown email address (marked as red)

If both matching lead and contact records are found, then the contact record is associated with the email activity.

 
Email messages from Dynamics 365 Lead, Contact, and Account The email from only matching lead, contact, or account will be tracked.

 

Even if the matching record is disabled, the email is tracked.

Here even if the create option is enabled, no lead or contact records are created.

Email messages from Dynamics 365 records that are email enabled. It considers all the entities with email enabled not just lead, contact and account.
Email messages in response to Dynamics 365 email Only replies or forwards of email messages that have been already tracked will be considered for tracking.
No email messages No email messages are tracked.

Check the details here –

https://docs.microsoft.com/en-us/dynamics365/outlook-addin/user-guide/set-option-automatically-track-incoming-outlook-email#automatically-track-email-messages

Hope it helps..

Advertisements