{"id":27,"date":"2025-04-23T17:33:23","date_gmt":"2025-04-23T17:33:23","guid":{"rendered":"https:\/\/dandltechnology.com\/?p=27"},"modified":"2025-04-23T17:36:28","modified_gmt":"2025-04-23T17:36:28","slug":"filter-customer-lookup-to-only-accounts","status":"publish","type":"post","link":"https:\/\/dandltechnology.com\/index.php\/2025\/04\/23\/filter-customer-lookup-to-only-accounts\/","title":{"rendered":"Filter Customer Lookup to only Accounts"},"content":{"rendered":"\n<p>If you want to restrict a lookup for the data type of customer there is a very simple way and it is not using prefiltering.<\/p>\n\n\n\n<p>Simple JavaScript and a few lines of code will provide this functionality.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\" style=\"margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40)\"><code>var formContext;\nfunction onLoad(executionContext) {\n    formContext = executionContext.getFormContext();\n    filterCustomerLookup();\n       \n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\" style=\"border-style:none;border-width:0px;margin-top:0;margin-bottom:0\"><code>function filterCustomerLookup() {\n    var customer = formContext.getControl('customerid');\n    if (customer.getEntityTypes().length &gt; 1) {\n        customer.setEntityTypes(&#91;'account']);\n    }\n};<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to restrict a lookup for the data type of customer there is a very simple way and it is not using prefiltering. Simple JavaScript and a few lines of code will provide this functionality.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6],"tags":[8,10,9],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-d365","category-javascript","tag-d365","tag-filter-lookup","tag-javascript"],"_links":{"self":[{"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":2,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":29,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/posts\/27\/revisions\/29"}],"wp:attachment":[{"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dandltechnology.com\/index.php\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}