Hi All,
Can anyone tell about few examples on actions in crm.
Here one I am trying example but not able to do.
Below example :
https://deepakexploring.wordpress.com/2013/10/23/actions-in-crm-2013/
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is EntityReference)
{
try
{
EntityReference eventObj = (EntityReference)context.InputParameters["Target"];
string projectName = (string)context.InputParameters["ProjectName"];
if (eventObj != null)
{
//Custom Validation
// Calling the Action
OrganizationRequest req = new OrganizationRequest("ags_CreateProjectUsingAction");
req["ProjectName"] = "This is a test operation for using Actions in CRM 2013 ";
req["Target"] = new EntityReference("ags_event", eventObj.Id);
//execute the request
OrganizationResponse response = service.Execute(req);
}
else return;
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("An Error occurred in plugin.", ex);
}
}
}
Please suggest anyone ??
Thanks,
Jharana