I am creating a plugin when button is clicked the issue is this plugin gets timeout error and i am new to dealing with CRM plugins so please if you would not mind highlight my issues for me i need to learn.
The process goes as following:
- Created a button to call Custom Action.
- Custom Actions trigger the plugin.
- plugin get stuck when reaching _service.update(member).
this is my code:
using (_serviceProxy = new OrganizationServiceProxy(orgConfigInfo, creds))
{
Guid NotAv = new Guid("F6115B90-0822-E811-80CC-C97E2A8B2DB3");
Guid ItsAv = new Guid("BAA14087-0822-E811-80CC-C97E2A8B2DB3");
_service = (IOrganizationService)_serviceProxy;
_serviceProxy.EnableProxyTypes();
EntityReference entityRef = (EntityReference)context.InputParameters["Target"];
Entity member = _service.Retrieve("gsadev_booksportsfacility", entityRef.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
DateTime startDate = Convert.ToDateTime(member.Attributes["gsadev_startdate"]);
DateTime endDate = Convert.ToDateTime(member.Attributes["gsadev_enddate"]);
EntityReference entref = (EntityReference)member.Attributes["gsadev_subfacility"];
Guid subFacility = entref.Id;
string sfLogicalName = entref.LogicalName;
EntityReference entreg = (EntityReference)member.Attributes["gsadev_requeststatus"];
Guid requestStatus = entref.Id;
string rsLogicalName = entref.LogicalName;
if (context.Depth <= 1)
{
// member.Attributes["gsadev_availabilitystatusid"] = ItsAv;
// member.Attributes.Add("gsadev_availabilitystatusid", NotAv);
member.Attributes["gsadev_availabilitystatusid"] = new EntityReference("gsadev_availabilitystatus", NotAv);
_serviceProxy.Update(member);// 3rd type of update
//_service.Update(member);
}
}
}
catch (Exception ex) {
string error = ex.Message;
}
}
}
}