web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update Plugins times out while trying to update one record.

(0) ShareShare
ReportReport
Posted on by

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:

  1. Created a button to call Custom Action.
  2. Custom Actions trigger the plugin.
  3. 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;
}
}
}
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    Hi,

    Never ever use ColumnSet(true) in any Plugin Code, especially when you are updating an entity. It actually performs Update on all fields of that entity in the database, which may invoke other Plugins and Workflows registered on those field's updates. So your process/transaction may get entered in Infinite Loop.

    Entity member = _service.Retrieve("gsadev_booksportsfacility", entityRef.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));

    Always use only those fields in Column Set that you are actually gonna use in Plugin. Like below:

    ColumnSet cols = new ColumnSet(
    new String[] { "name", "address1_postalcode", "lastusedincampaign", "versionnumber" });

    Entity retrievedAccount = _service.Retrieve("account", _accountId, cols);

    Can check my post here also - https://community.dynamics.com/crm/f/117/p/276417/788253#788253

    Hope you got the clarity.

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

  • Community Member Profile Picture
    on at

    Thanks for this information, now i have another issue where i have to click on the button twice so the field would be updated. by any chance do you know why is that happening?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans