Tag Archives: Plugin

Post Sync Plugins not allowed for certain System entities?

Hi,
I was getting some errors when trying to associate some records on creation of “User” and “Team” entities. I have registered “Post – Sync” step for those plugins.Getting following error for “Post” “Sync” plugin on “User” creation:
Error: usersettings with Id Does not Exist.

 

Getting following error for “Post” “Sync” plugin on “Team” creation:
Error: Generic SQL Error.

Changing them from “Post – Sync” to “Post – ASync” resolved the issue. It looks like SQL Locks might be causing the issue. There may be few more System entities for which the same is applicable. There is no documentation available specifying for which System entities creation “Post – Sync” plugins are not allowed. So, next time if you get any of the above errors for any of the other entities then try to change it to “ASync” and see whether it resolves your issue.

Hope it helps..!!! 🙂

How – To Series 13: How to Hide System Chart or User Chart Name in Dashboard

Hi all,
I have worked on one of the requirement to hide lables of all charts(System or User) in all the dashboards. This requirement has been done more than once for different instances. Thought of sharing so that it will be helpful to someone.         By default, Chart Name and view Name will be shown in every chart when it is displayed in a dashboard as follows:

Inorder to hide the chart lable, I thought of going with the following appraoch
              In Post Stage of chart retrieval, replace the chart name with an empty string.

Pluing Code:

public void Execute(IServiceProvider serviceProvider)

{
// Get the context

IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

// Check the required pre-requisits; if not, exit
if (!(context.MessageName.ToLower() == “retrieve” && (context.PrimaryEntityName.ToLower() == “savedqueryvisualization” || context.PrimaryEntityName.ToLower() == “userqueryvisualization”)))

return;
// Get the chart entity
Entity entity = (Entity)context.OutputParameters[“BusinessEntity”];

//Replace the chart name with empty string.
if (entity.Attributes.Contains(“name”))
entity.Attributes[“name”] = string.Empty;
}

As chart can be either System or User so register the plugin on following two steps:

 

Once plugin is registered, following is the result:

I have also shared the code here
Hope it helps..!!! 🙂

Cheers…
Vikranth

How-To Series 11: How To Trigger a plugin on Sharing a Record and Send An EMail

Hi All,
Today I have seen one forum post asking for Sending an email on Sharing a record. So, thought of implementing the same and blog it over here.
When a record is shared, a “PrincipalObjectAccess” record will be created in DB. However, we can’t register a plugin on “Create” Message for “PrincipalObjectAccess” entity. Instead, we can register it on “GrantAccess” message which will be triggered on sharing the record. So, simply register your plugin as follows:

Following is the piece of plugin code to get the details of record being shared and the users/team for whom the record has been shared. Here I am trying to send an email to the user for whom the record has been shared.

// The InputParameters collection contains all the data passed in the message request.if (context.InputParameters.Contains(“Target”) && context.InputParameters[“Target”] is EntityReference)

{// Entity Record which has been shared
EntityReference sharedRecord = ((EntityReference)context.InputParameters[“Target”]);
// System User for whom the record has been shared
EntityReference sysUser = ((PrincipalAccess)context.InputParameters[“PrincipalAccess”]).Principal;

// System User ID who has shared the record
Guid fromUserId = context.UserId;
// Send An EMail
SendEmail(service, sysUser, fromUserId, sharedRecord);
}

I have shared the entire plugin code over here: Here

PS: If we have shared the record to multiple users then this plugin will also be triggered multiple times. This means that, if you have shared a record to 5 users then an email will be sent to 5 users seperately not in a single shot.

Hope it helps…!!! 🙂