Skip to content

Category: Power Automation

EntitySetName Bookmarklet

Posted in Dynamics 365, Dynamics 365 Sales, Power Automation, and Power Platform

Almost six years after my last post about bookmarklets, I’m proud to present you a new bookmarklet for Dynamics 365 CE.

It can be used to retrieve the EntitySetName for for an entity (table).

In case you don’t know what the EntitySetName, here is what Microsoft writes about it.

This value is used in the resource path for this entity in the Web API. For custom entities, you can change the name of the entity set used. By default it is the same as the LogicalCollectionName.

Source: Microsoft Docs

In other words, you need when you use the WebApi or the Common Data Service (current environment) connector in PowerAutomate.

The EntitySetName Bookmarklet

Create a normal bookmark in you browser and replace its url with the following code:

javascript: etn=prompt("SchemaName?","account");var xhr=new XMLHttpRequest;xhr.open("GET","/api/data/v9.0/EntityDefinitions(LogicalName='"+etn+"')?$select=EntitySetName",!0),xhr.onload=function(t){4===xhr.readyState&&200===xhr.status&&prompt("EntitySetName:",JSON.parse(xhr.responseText).EntitySetName)},xhr.send();

You can use it at any place inside of D365 CE. You only need to write in the SchemaName of an entity (table) and it answers you with the EntitySetName from the EntityDefinitions.

Get CRM URL in Power Automate

Posted in Dynamics 365, and Power Automation

Sometimes you need to work with the URL of your CRM within Power Automate, for example:

  • to relate or unrelate two records with the Common Data Service (current environment) connector
    CDS (current) - Relate Records Action
  • or writing an email with a hyperlink to a record.

If you have a multi-staged environment and you build your Flow solution aware, you don’t want to update your static URLs after each transport.

Solution

‘Recycle’ the OData Id from a previous CDS action.

URL in OData Id of a Flow
  1. We need an previous CDS action that has an OData Id within its output (like shown above).
    If you have no action like this, consider to create a “List records” action which is limited to 1 by the “Top count” option.
  2. Create a “Compose” action and give it the OData_Id as input.
  3. Create an other “Compose” action and give it following expression to receive the CRM URL.
    concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
  4. Create an other “Compose” action and give it following expression to receive the OData URL.
    concat(join(take(split(outputs('OData_Id'), '/'), 6), '/'), '/')
Compose URL in Flow

How it works

  • concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
    Contains the OData Id we’ve stored in the first “Compose” action.
    "https://yourcrm.crm4.dynamics.com/api/data/v9.1/cdi_postedform(792189BA-BA04-E711-80F6-C4346BAC4DDC)"

  • concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
    Cuts the URL string in separate substring wherever a slash (‘/’) is.
    0: "https:"
    1: ""
    2: "yourcrm.crm4.dynamics.com"
    3: "api"
    4: "data"
    5: "v9.1"
    6: "cdi_postedform(792189BA-BA04-E711-80F6-C4346BAC4DDC)"

  • concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
    Merge the first 3 entries of the splitted URL to a new array.
    0: "https:"
    1: ""
    2: "yourcrm.crm4.dynamics.com"

  • concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
    Merge the new array into a string and separate the entries by a slash (‘/’).
    "https://yourcrm.crm4.dynamics.com" 

  • concat(join(take(split(outputs('OData_Id'), '/'), 3), '/'), '/')
    Create a new string with the merged URL and put a slash (‘/’) at its end.
    "https://yourcrm.crm4.dynamics.com/" 

In the same way you receive the OData URL when you “take” the first 6 elements instead of the first 3 elements.