Answered by:
plugin error while service.update

Question
-
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Download the details and load with Plug-in Profiler.
|7Rtbc+K2+q8wPHROH4zv3OrQ2U2yLdNuyYRkz5m+ybJE1DWSK8tJyK8/kmWbmwlO2g1khyew9N303SXZwc+P87h1j3hKGD1r2x2r3UIUsojQ2Vn79uaT0W+3fh4F1yhhXLQkME2H5Kx9J0QyNM2Hh4fOg9thfGY6lmWb//v8+xTeoTkwCE0FoBC1R8E5o5jMMg6E5NEiQ0ris7bgGWqb+WQq/0PB+EUBMqafSRyTFEFGo3RkBeZ+oFU6l48QJXt4TQXg4obM0cix7J5heYbdu7HdodsdOt2Oaw9sd9D7c43zEkUREuhRjH6IxU+NFPjDTPykgJ+GgC5uFgmSogn5c9a+irMZoZePCGZK5IJyu9D0U6XpNFdr2pkTyFnKsOhANldKd03bMqeIExCTp1w1Zvs1dipF/JilhKI0vaVEjCM16kIH9ZHlG2FodQ3Us22jb2Fs+FbXx24/dLrAVpjmNqoaPmeco1gbLR8cOIMBDB3HsK0BMryu1zX6A981Ih/ZvYHlWRHEOb0tTDV6IW17px40z+pRPY0lYyLh6ew2RVzjONjxXex2DRsg3/BcHxv9viPtjQchwKiLu30np1SHrIkmmbgCHMyRkGYudAv2WOaRK+vYtvIgwQEUaWmVcAszAgLAAqy0kWdaPXO6SAWad85ZHCOo1JB2fkFU2hpW5gLD39DiC4gzdAUIn2DprXIFhZeVQOHwK1qohxvAZ0jky63GNMC9IlF5JRheUkHEYoXNByEph5lA6etYxyAVVOpwP3M41JRKhcH9bpzLeQ2eWMsu6OckSw5mI1Ffth5lMGkvEu1f0NNwlpEol9F1IXQj6Y3Qez6W3mAFOIvjb2uRD3SGYtZ6W8Ms2Jx8p0uby7KCCYoYbbIwmVaQqlcvXVpNRfzzrVcYLponqWuEEUerNQw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9pK3W3PSy1IBh/VM1ua1r6Mob3iU+NWoBvlSanGllVkZXaLsY9REEKRUqVP1wWVJGZSqVR3kvTTvwcVJZKHBMjjZw8FFIRSS6ChMBGSSZDwq3hY7pCgsUV8BZPQYXEUmzujgQpRF5uCCEHrPCEQHl+PvjInDS6GzWqJfkzi4NKtt2TeQ48ivFGq2GVMhu/S8C9ZnAtWz7lxXCWyheHUo1Wc1aiT/aCf/PCeorjB2fDXkBeY+kCWNnZ8VVRBNPyqqQQh+Balsc+5lDF/SKGGEij+YIFid+ClAPTVSLAOzGWwwTgtFXKMkBotR3jYG5uZwsHbEM3KC9TOfUVCdjigNj/TlUGCujwbFO0nF9nJkd+zA3BgLNMPLe2ne3V3/zt5dMy7fferox1QZQO41Mo6e/cxMCan2IKOtN6wCs5oL/sv4Vyybj6YXOq+QtWTR+EjnH/CYCpSMo01VmPpbvtH/AQ==|Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ActivityId>20e7a7e6-5f59-44ee-be1e-e3683da1e1db</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">3</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>--------------------------------------------------------------------------------------------------
try {
if (context.Depth == 1)
{ IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity contact = (Entity)context.InputParameters["Target"];
Entity preimg = (Entity)context.PreEntityImages["test"];
Entity postimg = (Entity)context.PostEntityImages["test"];
string preimgstr = preimg.GetAttributeValue<string>("fullname");
string postimgstr = postimg.GetAttributeValue<string>("fullname");
if (preimgstr != postimgstr)
{
ColumnSet cols = new ColumnSet(new String[] { "lastname", "firstname", "address1_name" });
contact = service.Retrieve("contact", contact.Id, cols);
if (contact != null)
{
if (contact.Attributes.Contains("address1_name") == false)
{
Random rndgen = new Random();
contact.Attributes["address1_name"] = "first time value: " + rndgen.Next().ToString();
}
else
{
contact["address1_name"] = "i already exist";
}
service.Update(contact);
}}}}}------------------------------------------------------------------------------------------------------------------------
above is my try block to update my contact when the fullname is changed.Exeception occur when it reached to service.update.
Monday, April 17, 2017 1:49 PM
Answers
-
This is now profile is returned to a user if plugin is profiled.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Marked as answer by learner_test Tuesday, April 18, 2017 3:22 PM
Tuesday, April 18, 2017 12:43 PMModerator
All replies
-
Hello,
Looks like you have some plugin step that's profiled in your environment. Disable profiling and try to run your plugin again.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Proposed as answer by Andrii ButenkoMVP, Moderator Monday, April 17, 2017 2:07 PM
Monday, April 17, 2017 2:07 PMModerator -
Thanks Andrii Butenko for your reply ,
i have unregistered and registered back again without profiling ,its working fine now.Can u help with the reason behind this behavior.
profiling usually helps as to find and debug our error.so why they are causing exception while doing it.
Monday, April 17, 2017 2:39 PM -
Actually this is one of the ways to get trace of execution (this weird error text) - https://support.microsoft.com/en-us/help/2778280/step-by-step-working-with-crm2011-plugin-profiler so there's nothing unusual.
Dynamics CRM MVP
Read My blog
Subscribe for one of my coursesMonday, April 17, 2017 2:55 PMModerator -
so its a commonly occurring exception even when my plugin code are right.Tuesday, April 18, 2017 4:51 AM
-
This is now profile is returned to a user if plugin is profiled.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Marked as answer by learner_test Tuesday, April 18, 2017 3:22 PM
Tuesday, April 18, 2017 12:43 PMModerator -
thanks a lotTuesday, April 18, 2017 3:22 PM