Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Lead Assignment though C# Plugin, while creating it.

(0) ShareShare
ReportReport
Posted on by 40

Hello All, 

I had written a plugin code to assign leads to different users based on some conditions.

Registed at

message: create

event: Post Operation

Code is working fine till 
=> service.Update(entity);

but it is not making me to save the record/failed to create record through import or any

and throwing an error like:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Generic SQL error.Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>d2d4310b-a254-4a90-a74c-efb68c00b40d</ActivityId>
<ErrorCode>-2147204784</ErrorCode>

please help me to solve this asap.

*This post is locked for comments

  • Herald Jeramiah Profile Picture
    35 on at
    RE: Lead Assignment though C# Plugin, while creating it.

    Hi, You can progress in two ways

    1)Please Make sure any other plugin triggering on update of that entity. If so check Plugin Trace Log whether that plugin fails on update of that entity.

    There is no proper message on exception which you given, Maybe some other plugin may fail on the same pipeline.

    2)Instead of using post operation you can go through pre-event as Andrew Butenko suggested.

    Hope it helpful

  • Suggested answer
    ARIFNIIT Profile Picture
    1,391 on at
    RE: Lead Assignment though C# Plugin, while creating it.

    Resister Plugin on Pre-Operation and change owner filed value based on condition. no need to update it.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Lead Assignment though C# Plugin, while creating it.

    Try pre-event and just put new owner to ownerid field without update.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans