Power Platform Happy Hour in HCMC

It’s on! We are having Power Platform Happy Hour in Ho Chi Minh city. Feel free to join us and Ask – Connect – Share!

Saturday 18th May 10AM

The Open Space Coffee – 232/13 Vo Thi Sau, ward 7, district 3, HCMC

https://goo.gl/maps/jH1wX7Lbgaj5R9is5

#PPHH #HCMC #PowerPlatform #Dynamics365 #MicrosoftFlow #PowerApps #PowerBI

Advertisements

Retrieve Record using Alternate Keys

Instead of retrieve a single record using

Entity IOrganizationService.Retrieve(string entityName, Guid id, ColumnSet columnSet);

You can easily retrieve the record using its alternate keys if you don’t have the id in advance:

var keys = new KeyAttributeCollection
{
	{ "new_parent", parentRef.Id },
	{ "new_code", "code01" }
};

var request = new RetrieveRequest
{
	ColumnSet = new ColumnSet("field_logical_name"),
	Target = new EntityReference("entity_logical_name", keys)
};

try
{
	var response = (RetrieveResponse)service.Execute(request);
	if (response.Entity != null)
	{
		service.Delete(response.Entity.LogicalName, response.Entity.Id);
	}
}
catch (Exception)
{	
}

Note that if there is no record matched the keys, an exception will be thrown, you’ll need to handle the exception in that case.

The attribute with AttributeId = ‘guid’ was not found in the MetadataCache

I encountered this error when trying to export the solution from Dev environment. There was little information in the exception or the log file, but I could guess that something had been deleted and it didn’t update the MetadataCache (or the solution) somehow.

After googling, I found the solution is to delete the attribute/component from the CRM solution.

private static void RemoveComponentFromSolution(IOrganizationService service, Guid componentId, int componentType, string solutionName)
{
	RemoveSolutionComponentRequest removeRequest = new RemoveSolutionComponentRequest()
	{
		// this is the Guid you have found within your Dynamics 365 trace files
		ComponentId = componentId,
		ComponentType = componentType,
		// This is the unique name, not the display name of the solution you are trying to export
		SolutionUniqueName = solutionName
	};

	var response = service.Execute(removeRequest);
}

The component type can be retrieved using FetchXML

<fetch top="50" >
  <entity name="solutioncomponent" >
    <all-attributes/>
    <filter type="and" >
      <condition attribute="objectid" operator="eq" value="component guid here" />
    </filter>
  </entity>
</fetch>

Sync Office 365 User Photos to CRM Users with Flow

Background

I got a requirement that the client needs user profile photos in Office 365 to be synced to CRM Users. It is Dynamics 365 CE Online, and users don’t change profile photo often. There is no OOB way to achieve it so I need to develop custom synchronization.

Continue reading “Sync Office 365 User Photos to CRM Users with Flow”

“Record is unavailable” error when publishing solution

Problem

When publishing unmanaged solution, this error shows up

Record Is Unavailable

The requested record was not found or you do not have sufficient permissions to view it.

Although you have system admin role. Even worse, the download error log button is disabled and you can’t find out which component causing the error.

Solution

Clearly that there is something in the solution which you can see, but the system can’t.

If you try to pulish components one by one, there will be no error. But publishing all won’t work.

It will be quicker if you can narrow down what are added recently that may cause the error. Then you can use a different tool to publish the solution, either writing your own tool or use a plugin in XrmToolbox called “Manage Solution”, to catch the exception and see what the root cause is.

In my case it was a web resource, I deleted it and publishing all worked like a charm. Note that removing it from the solution doesn’t help.

Capture.PNG

Cheers!