List Rows, Select Columns, and Lookup field – Power Automate / Dataverse


Suppose we want to retrieve the value of the source campaign lookup of the lead records.

The schema name of Source Campaign is – campaignid

To get its GUID in the Select columns of list rows we can specify it as

_campaignid_value i.e. _lookupschemaname_value

The other option is if we specify the schema name in select columns then we need to use the expand property to get the GUID as well if we want any other attribute values e.g. text/label of the lookup field.


Hope it helps..

Advertisements

Using Coalesce Function to handle null value in Power Automate – Dataverse


Recently in one of our flows, we were getting the below error –

InvalidTemplate. Unable to process template language expressions in action ‘List_rows_:_Region’ inputs at line ‘0’ and column ‘0’: ‘The template language function ‘replace’ expects its first parameter ‘string’ to be a string. The provided value is of type ‘Null’. Please see https://aka.ms/logicexpressions#replace for usage details.’.

One or more fields provided is of type ‘Null’, a different type is expected.

This was because the replace function that we were using for the Filter rows property of List Rows (Dataverse) had the variable value as null.

Below was our dynamics expression where we replaced apostrophe with 2 single quotes – https://nishantrana.me/2023/02/27/how-to-handle-single-quote-apostrophe-in-filter-rows-in-power-automate-dataverse/

replace(replace(variables(‘varFieldData’)?[‘myVariable’],‘_’,’ ‘),””,”””)

The solution was to use coalesce function, to replace null with a blank string as shown below.

replace(replace(coalesce(variables(‘varFieldData’)?[‘myVariable’],”),‘_’,’ ‘),””,”””)

Similarly, we can use coalesce function to provide a default value.

The coalesce function will evaluate its arguments in order and will return the first non-blank or non-empty value. If all the arguments are blank or empty strings, the function will return blank.

After using the coalesce function, our flow was successful.

More on COALESCE

A similar example in SQL –

Hope it helps..

Advertisements

How to – Set Default value for the combo box in Canvas Apps (Dataverse)


Suppose we have the following Combo Box named Status bind to one of the choice fields of Dataverse.

Items = Asset Status option set field of table Product.

Now if we want Available to be the default selected value for it, we can use the DefaultSelectedItems property of the combo box.

DefaultSelectedItems = Filter(Choices(Products[@’Asset Status’]), Value = ‘Asset Status’.Available)

Also if we want to set the value of the Villages combo box based on the value selected in the Region combo box. The region is a lookup field in the Villages table.

We can update the Items property of the Villages combo box from

Villages (Data Source)

to

If(IsBlank(comboRegion.Selected),Villages, Filter(Villages, Region.Region = comboRegion.Selected.Region))

Hope it helps..

Advertisements

Calculated Column inside Plugin? – Dataverse / Dynamics 365


Recently while working on a plugin, we realized that for a particular column, we were not getting value in the context (on Post Create), the same was the case for Post Update and Post Image.

Also using Retrieve and RetrieveMultipleto fetch its value inside the Plugin didn’t work

Eventually, we realized it was a calculated column, which doesn’t give value inside the Plugin.

If we do RetrieveMultiple and RetrieveMultiple from a console app, outside Plugin, we get the value for that field.

Hope it helps..

 

Advertisements

Unable to install the Profiler. Unhandled Exception: System.InvalidCastException: Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type ‘CrmSdk.PluginType’ in Dynamics 365 / Dataverse


We might get the below error while trying to install the profiler in the Plugin Registration Tool.

“Unable to Install the profiler”

“Unhandled Exception: System.InvalidCastException: Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type ‘CrmSdk.PluginType’. at Microsoft.Crm.Tools.Libraries.OrganizationHelper.InstallProfiler(CrmOrganization org, String prtPath) at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.<>c__DisplayClass302_0.<InstallProfiler_Clicked>b__2(Object o, DoWorkEventArgs e)”

On closing the window we will get the below message “Profiler install failed”

Well we can ignore this error, just click on Refresh

After the refresh is completed,

we can see that the profiler has got installed successfully, even though we got the error.

Hope it helps..

 

Advertisements

Plugin registration profile record not getting created – Dataverse / Dynamics 365


Recently while trying to debug a plugin with Persist to Entity mode on the update step, we didn’t find any profile record getting created.

One option is to try to reinstall the profiler. This could happen when we are using a different version of the plugin registration tool and it has the Profiler already installed/configured from the other version of the tool.

If that doesn’t help, then opt for Exception mode, that has always worked.

Hope it helps..

Advertisements