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)

custom workflow - c# - get event that triggered?

(0) ShareShare
ReportReport
Posted on by

I would like to be able to set my custom workflow to be triggered by the 'create' and 'assigned'.  Is there a way in the API that we can figure out what event triggered the flow?  Maybe something in the CodeActivityContext?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Gus Gonzalez Profile Picture
    27,113 on at

    I don't understand the question...Workflows can be triggered automatically by Create and Assign.

    Are you having an issue?

  • Community Member Profile Picture
    on at

    I would like to be able to determine in the workflow what triggered it.  I need the workflow to behave differently based on how it was triggered.  Something like:

    if (from Create)
    else if (from Assign)

    ..something similar.  Right now I can get around this by just having two similar workflows, one called on each trigger but I think I saw somewhere you can see the trigger from workflow object.

  • Gus Gonzalez Profile Picture
    27,113 on at

    I would just create two workflows to be honest.

  • Community Member Profile Picture
    on at

    Is there a way to tell?  The code would change by one line by what triggered it.

  • Verified answer
    Gus Gonzalez Profile Picture
    27,113 on at

    That's why I'm leaning towards two workflows.

    You could put a "check condition" on the workflow where "if created on equals modified on" then fire workflow for "Created", if not (I.E. Assigned) then the dates won't match and the workflow fires the other code.

    I still think that two workflows are easier to spot and troubleshoot if you run into issues.

  • Community Member Profile Picture
    on at

    good point(s). thank you.

  • Gus Gonzalez Profile Picture
    27,113 on at

    No problem Scott, let me know if it worked.

  • KaiHartmann1981 Profile Picture
    204 on at

    Given the CodeActivityContext is called 'executionContext', and you get the Context like this:

    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

    The 'MessageName' property holds the trigger name ("Delete", "Create", etc.): context.MessageName

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