Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Event Handler not running for every Role

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey,

I want to avoid the system to send Appointments to Dynamics contacts, so I used this Event to prevent this:

function preventmail() {
if(Xrm.Page.ui.getFormType() == 1) {
Xrm.Page.getAttribute('requiredattendees').setValue('');
}
}

This is running correctly, but only for the administrative role! For regular rules it's not running. What's going on here?

Best,

Hannes

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hi Hannes_83,

    if you solved the problem or received help from an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    To complete this: I copied the role, assigned the new role - and this solved the problem. ;)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hi Hannes_83,

    im pretty sure user is member of a team with a role which allow limited operations on activities.

    Could you please check if user is member of some teams?

    Thanks

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    I did some research and found more:

    When I use a similiar Role which allows access to the Activites, it works and the rule runs fine. So the problem is:

    -> 'Creation' as 'Read Only' (You can not save this)

    -> JS is not running

    -> 'Creation in regular mode (You can save this)

    -> JS is running

    So the question is, why does this specific role allow to create Activities, even when there's no privilege assigned? Is there any other setting in the role which can affect this?

    Best,

    Hannes

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hey Francesco,

    I've verified something:

    a) There's only this role associated to this specific person. I've removed this role and the user couldn't log in.

    b) This role has noe privileges for activites

    c) I've re-assigned this role and the user can log-in directly

    d) The user can create activities, but they are all in Read-only, so you can not save them.

    Here I don't see any problem. I have the following setting which might be the reason:

    a) The User is associated to a specific Business Unit. This Business Unit is the highest in the hierarchy (there are only two at the moment).

    b) When I navigate to this team and go on 'Manage Roles', there's nothing selected. Also when I mark this user and click on 'Manage Roles', there's nothing selected.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hi Hannes_83,

    probably your user is member of a team which has a role with activity privilege enabled.

    Could you verify?

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hey,

    I have removed every privileges regarding activity - and still I can create Appointments, but only as 'Read Only'. I'm confused about this!

    Screenshot-5.PNG

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hi Hannes_83,

    it is definitely a role issue.

    Please post privilege screenshot about core entity of your user role.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hey Francesco,

    I've changed  this, but the problem is the same. What else confuses me is, that for the 'Regular User' the Appointment is in 'Read Only', while for the Admin it isn't. Can this be a reason and where to change this?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Event Handler not running for every Role

    Hi Hannes_83 ,

    javascript is not affected by role so there is some issue somewhere else.

    First: remove quotes and put null into required attendees Xrm.Page.getAttribute('requiredattendees').setValue(null);

    Second: move the method call to onload method to verify that it works.

    Third: add Xrm.Page.getAttribute('requiredattendees').setSubmitMode('always'); to be sure the attribute is not disabled for users different from administrator

    Finally your code should be this:

    function preventmail() {
    if(Xrm.Page.ui.getFormType() == 1) {
    Xrm.Page.getAttribute('requiredattendees').setValue(null);
    Xrm.Page.getAttribute('requiredattendees').setSubmitMode('always');
    }
    }

    Please let me know if you solve.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

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 Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans