Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Updating An Entity From Plugin Trips Workflow

(0) ShareShare
ReportReport
Posted on by
I have a plugin that is sending some Opportunity data to another system of ours when certain fields in the opportunity are updated and then I save the id of this new record from this other system back into the opportunity.  We have a workflow that runs when the status changes, it checks a few fields to verify they meet our requirements and if not, prevent the opp from going to the next sales stage.  Sometimes, not always, this workflow is tripped when I do an update on the opp even though the only thing I've changed is adding this id to this opportunity.  The sales stage never changes.  These required fields are missing but since the sales stage never changes and technically, we don't require these fields until the user tries to move it to the next sales stage, this should pass this workflow.  I've registered this plugin the /Post Operation/ pipeline stage because I want to make sure the opportunity is saved before this plug in runs.  Is there something I can do so that my plugin bypasses this validation?  Is there a better way I should be handling this scenario?  Is there something I need to check with our required field validation when sales stage changes?   I don't want to block the user form saving the opportunity, just want to be able to process some of the data after it's saved.  Below is an example of my code.
 
 IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
_service = factory.CreateOrganizationService(context.UserId);
 
if (context.InputParameters != null)
{
      Entity entity = (Entity)context.InputParameters[/Target/];
      Entity opp = (Entity)_service.Retrieve(/opportunity/, entity.Id, new ColumnSet(true));
 
    <Save some of the opp data to this other system and get back the id>
 
    opp.Attributes[/my_system_id/] = item.id;
   _service.Update(opp);
}
 

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,025 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans