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)

How to trigger a workflow only if record user has assigned a specific security role

(0) ShareShare
ReportReport
Posted on by 2,175

Hi all,

I've got a question hopefully someone here can help me with. We've got a situation in our organisation where appointments have checkbox field that when checked pulled the appointments into a custom SSRS report. 

What we've wanted to now do is setup a workflow that when appointments are tracked or created by users assigned to a specific security role that it automatically checks the checkbox field on the appointment, hence pulling their appointments automatically into the SSRS report. This way it saves users the extra clicks they need to do in order to mark an appointment for the report but I can't seem to figure this out with the out of the box workflows.

Will I need to setup some sort of  custom plugin step to do this?

Kind regards,

Mike

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,795 Super User 2025 Season 2 on at

    To preface this response, I'm a huge advocate for trying to do things functionally before writing plugin code. I can think of four ways you might be able to handle this functionally and without a plugin, but in the end it really depends on your business requirements.

    1) Could you just add some sort of checkbox or indicator to the user page that their appointments should show up in this report? Then you can have a workflow run on create of an appointment and check if the user should be included in the process. It takes an extra step after a security role, but would probably be the simplest way to handle this and will also allow you to add or remove someone from the report manually if needed in the future (without removing their security role).

    2) Use a free plugin / solution like Dynamics 365 Workflow tools, which already has the plugin code written to check for users being in a security role. The solution is easy to install and has some other neat features too

    3) If the user will always be on the form when it is saved (so you are not creating the appointment via workflow or other process), you could use JavaScript to check security roles of the user.

      • Xrm.Page.context.getUserRoles();will bring back the GUID of all security roles assigned to the user in an array. You could then check if the given role is included and, if so, use JS to set the boolean field to true

    4) This last one is really a work around if you truly do not have any developer resources, or if you need something done very quickly and the development side will take some time. It meets your requirements to be security role dependent, but is quite the work around. You could create a new entity and call it something like "Appointment Report". It can be a very basic entity that is only used for this purpose. Give the security role in question the ability to create this new record type, but nobody else. It should have a lookup field to an appointment record.

    • On create of an appointment, run a workflow to create a new "Appointment Report" record and point it to the appointment in question
    • On create of the new record type, have a workflow that will update the boolean checkbox on the appointment record on the lone lookup field

    When the workflow attempts to run on create of an appointment, only users with the security role will be able to create the new record, which in turn will update the boolean. Again, kind of a crazy work around but it would get the job done.

    I would recommend either of the first two solutions, but I believe any of the four would work. 

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    yes, you can create a plugin to achive that, you can refer below blog.

    rahuljim.blogspot.com/.../trigger-plugin-on-assignment-of.html

  • Rajesh Chungath Profile Picture
    467 on at

    You can write a small custom workflow activity to validate the user has the required role and return a bool value. Then add a pre condition in workflow and validate the value returned by the custom activity and if the user don't have the role you can cancel the workflow execution.

  • Community Member Profile Picture
    on at

    Could you solve the problem?

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