Notifications
Announcements
No record found.
Hi all
First, I'm completly new with javascript .....
I try to add a custom filter to my lookup field and I've copied this function from Microsoft Learn (https://learn.microsoft.com/it-it/power-apps/developer/model-driven-apps/clientapi/reference/controls/addcustomfilter).
The script is inserted in OnLoad event of page and work until red line, without giving errors (I put some popup to know where ) ... can somebody explain me where I'm mistaken?
Hello,
The answer is - you declare a function but you don't use it. Check this post - it gives a better explanation of how the filtering works - www.inogic.com/.../
Hello DiePic
I made a custom entity and I'm trying to get the name or id or anything that could work of an account from a lookup, and to apply a filter with that account on another lookup on opportunities, it means advance filter in lookup. below code i have done and its working for me.
Try with this -
function OnChangeOfAccount() {Xrm.Page.getControl("opportunityLookpField").addPreSearch(function () {addLookupFilter(); });}
function addLookupFilter() {if (XRM.Page.getAttribute("Accountlookuofield") != null) { var account = Xrm.Page.data.entity.attributes.get("Accountlookuofieldt").getValue()[0].id; // Xrm shhoud be smalll not like XRMif (account != null) {fetchXml = "<filter type='and'><condition attribute='parrentaccountid' operator='eq' value='" + account + "' /></filter>";Xrm.Page.getControl("opportunityLookpField").addCustomFilter(fetchXml); } }}
I hope it helps,Thanks.Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Portal.
Thanks for reply a33ik and Maulik Shah Your suggestion had make me find new material for my studies.
Now I've this script that apparently work well, but when I select the lookup field and press ENTER, the list is complete ... not filtered.
For all the rest i's working well.
Can you help me to correct this error?
Replace this line
with the line
if (formContext.getAttribute("ath_utente_collegato").getValue() != null) {
Hi a33ik
Your suggestion make me discover more concepts...
I've changed a little my script because I want that filter is starting every time that I press enter on lookup field.
Now the list is always complete (not filtered) and give me this error.
Can you help me more?
Remove the "order" part - it shouldn't be there
Thanks a lot a33ik
now it's working well !!!
Please only for my knowledge, there is a way to insert the string XML with order or not?
There is no way, as far as I know. It's possible to use only filters/conditions inside - so basically that's related to filtering.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 170 Super User 2025 Season 2
#ManoVerse 61
Gerardo RenterÃa Ga... 52 Most Valuable Professional