cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Filter the "Required Attendees" Field

Hi Community:

 

I'm almost a new developer here in Powerapps but I can manage my way thru, so I found out that we can use CDS to get entities all ready to use, however, when I use the "Appointment" entity I need to filter the "Required" filed that comes in the main form called "Appointment". By default, this field is linked to several entities but I just need to get the contacts entity to be shown in the current view and nothing else.

 

second higlighted valuesecond higlighted value

 

I've read that we can use JS to do this but my JS knowledge is null, if someone could of help me to do this or provide a link with a step by step solution I would really appreciate all of your help 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: Filter the "Required Attendees" Field

Try this 

 

function onLoad(context){
    var formContext=context.getFormContext();
    var c=formContext.getControl('requiredattendees').getAttribute();
    var e=c.getAttrDescriptor().Targets;
    var f=e.length;
    for (var g=0; g<f; g++){
        e.pop();
    }
    e.push("contact");
}

 

 which is the direct approach to the wrapper that seems to no longer exist.

 

This should just work as I was annoyed enough to experiment and find a suitable fix.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

8 REPLIES 8
Highlighted
Solution Sage
Solution Sage

Re: Filter the "Required Attendees" Field

 

You will need the following (it's untested but should work as it's just the code from https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/225447/party-list-customization-in... converted without testing to use context rather than Xrm.page.

 

function onLoad(context){
var formContext = context.getFormContext();
var lookupDataOAReqAttendees = formContext.getAttribute('requiredattendees').getLookupDataAttribute();
lookupDataOAReqAttendees.setLookupTypes(['contact']);  
}

 

Just add that script to a javascript library and run it on pageload passing in the executioncontext as the first parameter by checking the checkbox.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
Highlighted
Super User II
Super User II

Re: Filter the "Required Attendees" Field

HI @julhern,

There are a few ways you can approach this, top 2 that come to mind are:

  1. Create a sync aka real-time workflow to ensure only contacts are entered. Configure the workflow to run in real-time on create of update of Recipient/Required. If users tries to enter anything else, the system will through an error. Here's an example of the workflow and error:
    2020-09-22_19-49-06.png
    2020-09-22_19-50-39.png

  2. Create (or update) a new Appointment form and a new Contact lookup field. Add the new field to the form to replace the original field. 
    Note: make sure you also update (or create new) the quick create appointment form because the original field is also there. Note 2: if you create new forms, remove the old Appointment and quick create forms from your model-driven app.

Hope this helps!

Highlighted
Solution Sage
Solution Sage

Re: Filter the "Required Attendees" Field

@EricRegnier How do those approaches restrict the access on the form to just contacts without breaking the behind the scenes O365 diary functionality and by breaking the required attendees field you are going to end up with a Outlook appointment that doesn't match the D365 / power app appointment record.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
Highlighted
Super User II
Super User II

Re: Filter the "Required Attendees" Field

If you’re referring to appointment sync with Exchange integration, then I’m assuming @julhern is not syncing appointments.

Highlighted
Regular Visitor

Re: Filter the "Required Attendees" Field

Hi All:

 

as @EricRegnier mentions, I will not sync with outlook yet, maybe in the future, now I'm using a flow to create a google event because my team has the google suite but maybe in a near-future my team and I will move over to O365.

 

Let me give it a try to what both of you mentioned and let you know the outcome. 

 

Thank you all

Highlighted
Regular Visitor

Re: Filter the "Required Attendees" Field

Hi @ben-thompson 

 

I tried your solution today morning and it gave me the following messages (probably is my null knowledge in JS):

 

so I added the script here to the left and its called cr856pwfs_hideentities:

 

Entity4.png

 

and then I guessed that the function was the one inside of the script so I added to the function box on the right. but it gave me this error message:

 

Entity5.png

 

I also attached the error log. 

Thank you

Highlighted
Solution Sage
Solution Sage

Re: Filter the "Required Attendees" Field

Try this 

 

function onLoad(context){
    var formContext=context.getFormContext();
    var c=formContext.getControl('requiredattendees').getAttribute();
    var e=c.getAttrDescriptor().Targets;
    var f=e.length;
    for (var g=0; g<f; g++){
        e.pop();
    }
    e.push("contact");
}

 

 which is the direct approach to the wrapper that seems to no longer exist.

 

This should just work as I was annoyed enough to experiment and find a suitable fix.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

View solution in original post

Highlighted
Regular Visitor

Re: Filter the "Required Attendees" Field

Hi @ben-thompson 

 

This Actually did the trick thank you for your time and your input !

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (5,101)