Thursday, October 24, 2013

addCustomFilter method for lookup control in CRM2013

In CRM2011, Microsoft introduced a new method “addCustomView” to filter the lookup dialogs.  The process was a bit complicated. You have to create a unique guid, fetchxml, layoutxml and few other things.
In the new release, Dynamics team has introduce a new method addCustomFilter. It makes it very easy to apply filters to the lookup dialog. But there is one gotcha.This method can only be called from a “PreSearch” event handler of the lookup control. This event get triggered as the user is about to view results for the lookup.
We can add and remove the event handler to the PreSearch event using addPreSearch(handler) and removePreSearch(handler) methods.
In this blog, I am going to filter the parent customer lookup on the contact entity based on the city of the contact. Here is the code.

Code

function addEventHandler() {
    // add the event handler for PreSearch Event
    Xrm.Page.getControl("parentcustomerid").addPreSearch(addFilter);

}

function addFilter() {
    //check if the city is not empty
    
    if (Xrm.Page.getAttribute("address1_city").getValue() != null) {
        var city = Xrm.Page.getAttribute("address1_city").getValue();
        //create a filter xml
        var filter ="<filter type='and'>" +
                     "<condition attribute='address1_city' operator='eq' value='" + city + "'/>" +
                     "</filter>";
        //add filter
        Xrm.Page.getControl("parentcustomerid").addCustomFilter(filter);

    }
}

I am calling the addEventHandler function on the form load event.
The addEventHandler() function is used to attach the event handler to the PreSearch event of the “parentcustomerid” lookup of contact entity.
The addFilter() function will be called when the PreSearch event is triggered.

Screen Shot


image
In the screen shot above, the lookup is displaying accounts and  contacts where city is equal to ‘Renton’

Things to remember


addCustomFilter method takes two parameters ‘filter’ and the ‘entityLogicalName’. The entityLogicalName is optional and if this parameter is provided, the filter will only apply to that entity type. Otherwise it will apply to all types of entities returned.

For e.g. customer lookup control display account and contact records. If we don’t provide entityLogicalName  parameter, the filter will apply to both account and contact records and if we provide “account” as a  parameter then filter will only be applied to account records not to contact records.
  

28 comments:

  1. Doubt that works. city value not used anywhere.

    Jeff

    www.xrmschool.com

    ReplyDelete
    Replies
    1. thanks mate. the code does work. I forgot to encode the XML.

      Delete
    2. Hello my name is favour Johnson from south African married with three kids Mary joy and rose lost my husband four years ago. Since then things have become hard for me and my children even to eat was a problem because they have no money to buy food stuff and to pay my children's school fees. April 12 2017 a friend of my gave me contact of agent Williams that help her on blank ATM card that make her to be rich now and she said the card can be use in any bank without trace so are contact the man and him ask me to send my bank details which him we use for the ATM card which are did and are send it in two days him contact me back and said my ATM card is ready and are pay some money to the DHM that send the card to me in South African in three days of it are got my ATM card and my code which are can use to we draw money in any bank now me and my family are now living better now are want to thank agent Williams by telling him thank you and may God reward you for your good work tool ward our life you can contact on his email (internationalhackingcompany@gmail.com) you can also contact him on +17068042665.

      Delete
    3. HEY GUYS,.. Joy Allen is my name….
      Am so happy to be here, and letting you all know how my life was changed
      for good, I read a post online about an ATM hacking card which i also give
      it a try,And i received it from the hacker called Mr Frank last week and
      now I have $150,000 for free. The blank ATM withdraws money from any ATM
      machines and there is no name on it, it is not traceable and now i have
      money for business and enough money for me and my family to live on .I am
      really happy i met Mr Frank who transformed my life and that of my family,
      After he has finished preparing the ATM he then now send the card through
      shipment to me, friends you can order for your on atm hacking today he is
      giving it out for a low price to help people even if it is illegal but it
      helps a lot and no one ever gets caught. i am grateful to Mr Frank because
      he changed my story all of a sudden . The card works in all countries
      except. mr Frank email address:  mrfrankblankatmcard@gmail.com  website:; https://mrfrankblankatmcar8.wixsite.com/mrfrankblankatmcard

      Delete
    4. iI’m lauriel from New York, United States. I lost my job a few months back after my divorce with my wife. I tried everything positive to make sure I took good care of my kids but all failed, and I was in debt which makes everything worse. I was kicked out of my home and i had to live with my neighbor after pleading with her to allow me to stay with her for some days while I figured out how to get a home which she agreed to, but no one was willing to help anymore. I bumped into this page from google and I was excited about this, then I contacted the hackersBill Dean. I had just $200, so I pleaded with them to help me because of my condition but they never accepted. I believed in this, so I managed to pawn a few things and got $500. I ordered the $10,000 card and I got my card delivered to me by Ups 4 days later. I never believed my eyes! I was excited and upset as well, I managed to withdraw $2000 on the ATM and $2500 the second day. I went to Walmart and a grocery store and bought a couple of things for $3000. The card got blocked the third day and I contacted them and I was told it's a mistake from my end. I’m so happy, I have started all over again and have a good apartment with my kids you can contact him through is via email (globalatmcardhackingservice@gmail.com)or his whatsap contact (+1 301-887-5071) 

      Delete
  2. is it possible to use this method to limit a lookup to an entity, I.e the customerid on the opportunity to just a contact and not the account as well?

    Thanks

    ReplyDelete
  3. Hi Pete, did you fix the issue to limit the lookup custom filter to return just one entity type?

    ReplyDelete
  4. Hi Amreek, is there any way to restrict or default CustomerID lookup only to contacts using supported way?

    ReplyDelete
  5. Is there any way to specify columns

    ReplyDelete
  6. Thank you! This solution works in the classic interface in Dynamics 365 but not in the Unified interface. Could you please let me know if there is a way to make this work in Unified interface in Dynamics 365?

    ReplyDelete
  7. My ex ruined me broke due to his incessant extravagant spending , I found myself in a big mess. I talked to a loan company and I was told that they can't lend me loan . I was devastated, that's put me into a lot of debt. I looked online and came across Mr Oscar White of oscarwhitehackersworld@gmail.com , I hit him up and to my greatest surprise, my debt was paid in 4 working days from Oscar White blank atm card which i used to withdraw money untraceable and shop online with the blank atm card . I was so amazed and it didn't cost me too much to get the card and today have made up to $50,000.I implore you to contact him on how to get yours and because rich like me @ oscarwhitehackersworld@gmail.com or whats-app +1(323)-362-2310.No doubt he's the best out there and your problems will be solved!

    ReplyDelete
  8. Are you in a financial crisis, looking for money to start your own business or to pay your bills?
    GET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE*
    We sell this cards to all our customers and interested buyers
    worldwide,Tho card has a daily withdrawal limit of $5000 and up to $50,000
    spending limit in stores and unlimited on POS.

    YOU CAN ALSO MAKE BINARY INVESTMENTS WITH LITTLE AS $500 AND GET $10,000 JUST IN SEVEN DAYS

    **WHAT WE OFFER**

    *1)WESTERN UNION TRANSFERS/MONEY GRAM TRANSFER*
    *2)BANKS LOGINS*
    *3)BANKS TRANSFERS*
    *4)CRYPTO CURRENCY MINNING*
    *5)BUYING OF GIFT CARDS*
    *6)LOADING OF ACCOUNTS*
    *7)WALMART TRANSFERS*
    *8)BITCOIN INVESTMENTS*
    *9)REMOVING OF NAME FROM DEBIT RECORD AND CRIMINAL RECORD*
    *10)BANK HACKING*
    **email blankatmmasterusa@gmail.com *
    **you can also call or whatsapp us Contact us today for more enlightenment *
    *+1(539) 888-2243*
    **BEWARE OF SCAMMERS AND FAKE HACKERS IMPERSONATING US BUT THEY ARE NOT
    FROM *
    *US CONTACT US ONLY VIA THIS CONTACT **
    *WE ARE REAL AND LEGIT...........

    2020 FUNDS/FORGET ABOUT GETTING A LOAN..*

    IT HAS BEEN TESTED AND TRUSTED

    ReplyDelete
  9. Are you in a financial crisis, looking for money to start your own business or to pay your bills?
    GET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE*
    We sell this cards to all our customers and interested buyers
    worldwide,Tho card has a daily withdrawal limit of $5000 and up to $50,000
    spending limit in stores and unlimited on POS.

    YOU CAN ALSO MAKE BINARY INVESTMENTS WITH LITTLE AS $500 AND GET $10,000 JUST IN SEVEN DAYS

    **WHAT WE OFFER**

    *1)WESTERN UNION TRANSFERS/MONEY GRAM TRANSFER*
    *2)BANKS LOGINS*
    *3)BANKS TRANSFERS*
    *4)CRYPTO CURRENCY MINNING*
    *5)BUYING OF GIFT CARDS*
    *6)LOADING OF ACCOUNTS*
    *7)WALMART TRANSFERS*
    *8)BITCOIN INVESTMENTS*
    *9)REMOVING OF NAME FROM DEBIT RECORD AND CRIMINAL RECORD*
    *10)BANK HACKING*
    **email blankatmmasterusa@gmail.com *
    **you can also call or whatsapp us Contact us today for more enlightenment *
    *+1(539) 888-2243*
    **BEWARE OF SCAMMERS AND FAKE HACKERS IMPERSONATING US BUT THEY ARE NOT
    FROM *
    *US CONTACT US ONLY VIA THIS CONTACT **
    *WE ARE REAL AND LEGIT...........

    2020 FUNDS/FORGET ABOUT GETTING A LOAN..*

    IT HAS BEEN TESTED AND TRUSTED

    ReplyDelete
  10. email: visacreditcardsolution@gmail.comGET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE*
    **We sell these cards to all our customers and interested buyers
    worldwide,the card has a daily withdrawal limit of $5000 and up to $50,000
    spending limit in stores and unlimited on POS.**

    **WHAT WE OFFER**

    *1)WESTERN UNION TRANSFERS/MONEY GRAM TRANSFER*
    *2)BANKS LOGINS*
    *3)BANKS TRANSFERS*
    *4)CRYPTO CURRENCY MINNING*
    *5)BUYING OF GIFT CARDS*
    *6)LOADING OF ACCOUNTS*
    *7)WALMART TRANSFERS*
    *8)BITCOIN INVESTMENTS*
    *9)REMOVING OF NAME FROM DEBIT RECORD AND CRIMINAL RECORD*
    *10)BANK HACKING*

    ReplyDelete

  11. I've been seeing posts and testimonials about BLANK ATM CARD but I never believed it, not until I tried it myself. It was on the 12th day of March. I was reading a post about places to visit in Slovakia when I saw this captivating post about how a Man described as Mr Harry changed his life with the help of a Blank Atm Card. I didn't believe it at first until I decided to reach him through the mail address attached to the post. To my greatest imagination, it was real. Right now am living up to a standard I never used to live before. Today might be your lucky day! Reach Mr Harry via email: (harrybrownn59@gmail.com) see you on the brighter side of life. you can also text him on his number:+1(661)-797-0921

    ReplyDelete
  12. I want to share my testimony on how i got the blank ATM card. I was so wrecked that my company fired me simply because i did not obliged to their terms, so they hacked into my system and phone and makes it so difficult to get any other job, i did all i could but things kept getting worse by the day that i couldn’t afford my 3 kids fees and pay my bills. I owe so many people trying to borrow money to survive because my old company couldn’t allow me get another job and they did all they could to destroy my life just for declining to be among their evil deeds. haven’t given up i kept searching for job online when i came across the testimony of a lady called Judith regarding how she got the blank ATM card. Due to my present state, i had to get in touch with Hacker called OSCAR WHITE of oscarwhitehackersworld@gmail.com and he told me the procedures and along with the terms which i agreed to abide and i was told that the Blank card will be deliver to me without any further delay and i hold on to his words and to my greatest surprise, i received an ATM card worth $4.5 million USD , All Thanks to OSCAR WHITE , if you are facing any financial problem contact him asap email address is oscarwhitehackersworld@gmail.com or whats-app +1(323)-362-2310

    ReplyDelete

  13. Cool way to have financial freedom!!! Are you tired of living a poor life, here is the opportunity you have been waiting for. Get the new ATM BLANK CARD that can hack any ATM MACHINE and withdraw money from any account. You do not require anybody’s account number before you can use it. Although you and I knows that its illegal,there is no risk using it. It has SPECIAL FEATURES, that makes the machine unable to detect this very card,and its transaction can’t be traced .You can use it anywhere in the world. With this card,you can withdraw nothing less than $4,500 a day. So to get the card,reach the hackers via email address : besthackersworld58@gmail.com or whatsapp him on +1(323)-723-2568

    ReplyDelete

  14. I have being hearing about this blank ATM card for a while and i never really paid any interest to it because of my doubts. Until one day i discovered a hacking guy called Mr. Oscar White, he is really good at what he is doing. Back to the point, I inquired about The Blank ATM Card. If it works or even Exist. They told me Yes and that its a card programmed for random money withdraws without being noticed and can also be used for free online purchases of any kind. This was shocking and i still had my doubts. Then i gave it a try and asked for the card and agreed to their terms and conditions. Hoping and praying it was not fake. One week later i received my card and tried with the closest ATM machine close to me, It worked like magic. I was able to withdraw up to $6000. This was unbelievable and the happiest day of my life with my girlfriend Laurel. So far i have being able to withdraw up to $78000 without any stress of being caught. I don't know why i am posting this here, i just felt this might help those of us in need of financial stability. blank ATM has really change my life. If you want to contact them, Here is the email address: oscarwhitehackersworld@gmail.com or what's-app him +1(513)-299-8247 .

    ReplyDelete
  15. Hello my name is favour Johnson from south African married with three kids Mary joy and rose lost my husband four years ago. Since then things have become hard for me and my children even to eat was a problem because they have no money to buy food stuff and to pay my children's school fees. April 12 2017 a friend of my gave me contact of agent Williams that help her on blank ATM card that make her to be rich now and she said the card can be use in any bank without trace so are contact the man and him ask me to send my bank details which him we use for the ATM card which are did and are send it in two days him contact me back and said my ATM card is ready and are pay some money to the DHM that send the card to me in South African in three days of it are got my ATM card and my code which are can use to we draw money in any bank now me and my family are now living better now are want to thank agent Williams by telling him thank you and may God reward you for your good work tool ward our life you can contact on his email (internationalhackingcompany@gmail.com) you can also contact him on +17068042665.

    ReplyDelete
  16. GET RICH IN LESS THAN THREE DAYS...THIS IS NOT A JOKE
    withdraw $5000 dollars in one day with this card
    i want everyone to be rich like me,i want everyone to partake on this new trick called programmed blank ATM card,i got a card from this hacking company that is why i am sharing the good news to the world,BLANK ATM CARDS ARE REAL, thank you. brainhackers@aol.com
    website https://expertatmhackersrealmachineshackers.wordpress.com

    ReplyDelete
  17. INSTEAD OF GETTING A LOAN,, I GOT SOMETHING NEW
    Get $10,050 USD every week, for six months!

    See how it works
    Do you know you can hack into any ATM machine with a hacked ATM card??
    Make up you mind before applying, straight deal...
    Order for a blank ATM card now and get millions within a week!: contact us
    via email address:: besthackersworld58@gmail.com or whats-app +1(323)-723-2568

    We have specially programmed ATM cards that can be use to hack ATM
    machines, the ATM cards can be used to withdraw at the ATM or swipe, at
    stores and POS. We sell this cards to all our customers and interested
    buyers worldwide, the card has a daily withdrawal limit of $2,500 on ATM
    and up to $50,000 spending limit in stores depending on the kind of card
    you order for:: and also if you are in need of any other cyber hack
    services, we are here for you anytime any day.
    Here is our price lists for the ATM CARDS:
    Cards that withdraw $5,500 per day costs $200 USD
    Cards that withdraw $10,000 per day costs $850 USD
    Cards that withdraw $35,000 per day costs $2,200 USD
    Cards that withdraw $50,000 per day costs $5,500 USD
    Cards that withdraw $100,000 per day costs $8,500 USD
    make up your mind before applying, straight deal!!!

    The price include shipping fees and charges, order now: contact us via
    email address::besthackersworld58@gmail.com or whats-app +1(323)-723-2568

    ReplyDelete
  18. Have you pay your necessary BILLS? Do you need money? Do you want a better way to transform your own life? My name his Elizabeth Maxwell. I am here to share with you about Mr OSCAR WHITE new system of making others rich with not less than two to three days.I was in search of a job opportunity on the internet when i come across his aid on a blogs that i was on to, talking on how he can help the needy with a programmed BLANK ATM CARD.I thought it was a scam or normal gist but i never had a choice than to contact him cause i was seriously in need of Finance for Business.I contacted him on the CARD, and not less than a minute he respond and give me the necessary information’s on how to get the card. My friends, today am a sweet happy woman with good business and a happy family. I charge you not to live by ignorance.Try and get an ATM card today through (MR OSCAR WHITE)and be among the lucky ones who are benefiting from this card. This ATM card is capable of hacking into any ATM machine anywhere in the world.It has really changed my life and now I can say I’m rich because I am a living testimony. The less money I get in a day with this card is $15,000.Every now and then money keep pumping into my account. Although is illegal, there is no risk of being caught, as it is programmed so that it can not trace you, but also has a technique that makes it impossible for the CCTV to detect you.. I urge you to contact him on the BLANK ATM CARD. For details on how to get yours today, email hackers oscarwhitehackersworld@gmail.com ,whats-app +1(209)-643-1515

    ReplyDelete
  19. HAVE YOU BEEN IN SEARCH FOR GENUINE HACKER'S ONLINE?. HAVE YOU LOST YOUR MONEY TO BINARY OPTION SCAM OR ANY ONLINE SCAM WHATSOEVER?. WELL, YOU HAVE FOUND REDEMPTION .

    BLANK ATM CARD :We have specially programmed BLANK ATM CARDS that can be used to hack any ATM machine, these ATM cards can be used to withdraw at the ATM or swipe, stores and outlets. We sell this BLANK CARDS to all our customers and interested buyers worldwide, the BLANK CARDS has a daily withdrawal limit of $5000 in ATM and up to $50,000 spending limit in stores. and also if you are in need of any other cyber hacking services, we are here for you at any time any day. Email :
    Email:Creditcards.atm@gmail.com
    WhatsApp: +1(539) 888-2243

    -hack into any kind of phone
    _Increase Credit Scores
    _western union, bitcoin and money gram hacking
    _criminal records deletion
    _BLANK ATM/CREDIT CARDS
    _Hacking of phones(that of your spouse, boss, friends, and see whatever is being discussed behind your back)
    _Security system hacking...and so much more. Contact THEM now and get whatever you want at
    Email:Creditcards.atm@gmail.com
    WhatsApp: +1(539) 888-2243
    You can also contact us on Telegram.
    ����������✔����������������������������

    ReplyDelete
  20. (NO MEMBERSHIP FEE TO JOIN ILLUMINATI), I am giving a testimony on how i became rich and famous today… i was deeply strangled up by poverty and i had no body to help me, and also i searched for help from different corners but to no avail… I see people around me getting rich but to me i was so ashamed of my self so i met a man on my way he was very rich and he was a doctor so he told me something and i thought over it through out the day so the next day i looked up and i keep repeating what he said to me.” if you want to get rich quick and be famous” you need to cross your heart and do what is in your mind so i tried all i could in other for me to do as he said so later on i told my fellow friend about this same thing then my friend was interested in my suggestions so i decided to look in the internet and i found an email of an agent Jackson illuminatiriches50085@gmail.com and we decided to contact them and fortunately we did as they instructed us to do and later, they told us to get some requirements and all the rest… so this initiation took us just a week and later on the great Illuminati gave us $7,000,000.00 to start up our lives…. and now am testifying that if in any case you want to join any great Illuminati all you need to do is for you to contact him on whats-app +1(409)2993890.

    ReplyDelete
  21. One of the best hackers out there now Brillianthackers800@gmail.com, They can help with low credit scores, spy on your spouses to know if they are cheating, clear bad criminal record (databased)...... Just name it any kind of hack you want to think of they can break the code and get the job done, they are reliable, thrust worthy and they deliver right on time, the kind of job they carried for me private and the best part of it all your secret is save with them, you can chat with them via whatsapp 14106350697 and the rest will be history trust me.

    ReplyDelete
  22. CryptoCurrency RecoveryMasters:

    If you need any genuine hacker and you want to be prevented from the so called scammers who rip people of their money, RecoveryMasters got you covered, He's a secured Hacker from USA who deal with cyber issues of all kind, such as WhatsApp hack, Facebook hack, gmail hack, mobile phone hack, accounts hack, erase criminal records, websites hack, Bitcoin Trade, and other hack relating to cyber issues.
    Visite RecoveryMasters or Contact them on
    Email: (Recoverymasters@email.cz)
    whatsapp +1(551) 202-23-35
    Don't forget to say Victoria perks Recommended you

    ReplyDelete
  23. Hello everyone i'm Cliff by name I never imagined it would have been possible to recover my bitcoins.. RECOVER YOUR STOLEN BITCOIN OR MONEY LOST TO SCAMMERS WITH A LEGIT RECOVERY EXPERT: Have you ever been a victim of online scam? or have you lost your money to fake hackers online? I implore you to contact this trustworthy hacker and recovery expert by name smartlucasrecovery@gmail.com. I was a victim of fake people posing as binary options and bitcoin investors, I lost a sum of $4,000 and 2BTC from my bitcoin wallet to these fake brokers.It took a while before I realized they were scams and this really hurt me. Then an in-law of mine heard about it and recommended me to a specialist with the address smartlucasrecovery@gmail.com ... or what'sapp ((+4915214137658)),. He helped me recover my lost bitcoin in less than 48hrs and the scammers were caught and made to pay for what they did to me. If you have lost any amount to online scammers and you’re seeking to recover loss from wallet hackers, fake hackers, online dating scams, btc wallet hack, recovery of lost funds from fake binary investors or any online scam. Reach out to smartlucasrecovery@gmail.com or what'sapp ((+4915214137658)), with the best service to help you, and you will be so glad you did so, best believe recovery expert referral

    ReplyDelete
  24. Using the newest technologies is essential to staying ahead in the ever changing world of digital currency. Craker cyberdude Recovery is aware of this and uses state-of-the-art equipment and software to facilitate their recovery attempts. They make use of a variety of resources, such as data mining tools, blockchain explorers, and transaction analysis software, to increase the likelihood of success. Craker cyberdude Recovery presents itself as a pioneer in the bitcoin recovery services industry with its tech-savvy approach. While it may seem impossible, craker cyberdude Recovery is an expert at recovering bitcoins that have been misplaced or stolen. They commence their approach by collecting all relevant data on the lost bitcoins and doing a comprehensive scenario assessment. Then, using their knowledge of blockchain technology and cryptocurrency forensics, they take a methodical approach to find and track down the lost money. Craker cyberdude Recovery works to return your bitcoins to your digital wallet by utilizing a combination of cutting-edge tools and painstaking research. Craker cyberdude Recovery doesn't merely rely on conjecture or chance. They trace the flow of money and look for trends in blockchain transactions by analyzing them using sophisticated forensic techniques. They can find important information this way that may help recover missing bitcoins. Their staff of professionals is skilled at tracking transactions and utilizing blockchain data, which allows them to deftly negotiate the convoluted world of cryptocurrencies. When it comes to bitcoin recovery, security and confidentiality are paramount. Craker cyberdude Recovery recognizes the sensitivity of these matters and ensures that your personal information and recovery details remain strictly confidential. Email Craker(at)cyberdude. Com for more information.
    WhatsApp:+1 (931) 241-9477
    Website: https://crakercyberdude.space/
    Thank you.

    ReplyDelete