{"id":203,"date":"2019-10-02T16:35:32","date_gmt":"2019-10-02T16:35:32","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=203"},"modified":"2020-09-08T14:53:10","modified_gmt":"2020-09-08T09:23:10","slug":"custom-autocomplete-lookup-on-related-field","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/","title":{"rendered":"custom autocomplete lookup on related field"},"content":{"rendered":"\n<p>We came across a requirement where client wanted custom autocomplete lookup so after much searching , We found a way to do this.<\/p>\n\n\n\n<p>Steps are as below,<\/p>\n\n\n\n<p><strong>Step 1 :<\/strong>  Copy your &lt; desired_module &gt; editviewdefs.php file to custom\/modules\/&lt; desired_module &gt;\/metadata\/editviewdefs.php <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$viewdefs&#91;'&lt;desired_module>']&#91;'EditView']&#91;'templateMeta']&#91;'includes'] =\n    array (\n        array (\n        'file' => 'custom\/modules\/&lt;desired_module>\/js\/editview.js',\n        ),\n    );\n?><\/code><\/pre>\n\n\n\n<p><strong>Step 2 :<\/strong>  Add the JavaScript file you want to include into the location you referenced above(custom\/modules\/&lt;desired_module&gt;\/js\/editview.js). <\/p>\n\n\n\n<p><strong>Step 3 :<\/strong>  Write following code in editview.js file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SUGAR.util.doWhen(\n  \"typeof(sqs_objects) != 'undefined' &amp;&amp; typeof(sqs_objects&#91;'EditView_&#91;relate field name]']) != 'undefined'\",\n  functionQS\n);\n\nfunction functionQS()\n{\nsqs_objects&#91;'EditView_&#91;relate field name]']={\n    \"form\":\"EditView\",\n    \"method\":\"query\",\n    \"modules\":&#91;\"&#91;module name]\"],\n    \"group\":\"or\",\n    \"field_list\":&#91;\"name\", \"id\"],\n    \"populate_list\":&#91;\"&#91;name of relate field name\",\"&#91;name of hidden relate field id\"],\n    \"required_list\":&#91;\"parent_id\"],\n    \"conditions\":&#91;\n       {\"name\":\"name\",\"op\":\"contains\",\"value\":\"\"} \/\/ this can be contains, like_custom, equal, and you can add \"begin\" or \"end\" keys with % for sql search\n    ],\n    \"order\":\"name\",\n    \"limit\":\"30\",\n    \"no_match_text\":\"No Match\"\n};\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note : <\/strong><\/p><cite> <em>1. Read the comments in code carefully and replace the variables as asked.<\/em><br><em>2. Here, &lt;desired_module&gt; means the module name you see in the URL, for example, Contacts, Leads, Accounts, etc.<\/em> <\/cite><\/blockquote>\n\n\n\n<p>Hope this helps and feels like missing piece is just found!<\/p>\n\n\n\n<p>Feel free to drop your comments.<\/p>\n\n\n\n<p>Your valuable feedback means a lot.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We came across a requirement where client wanted custom autocomplete lookup so after much searching , We found a way to do this. Steps are as below, Step 1 : Copy your &lt; desired_module &gt; editviewdefs.php file to custom\/modules\/&lt; desired_module &gt;\/metadata\/editviewdefs.php Step 2 : Add the JavaScript file you want to include into the location [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[12,13],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>custom autocomplete lookup on related field - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"custom autocomplete lookup on related field - TechCRM\" \/>\n<meta property=\"og:description\" content=\"We came across a requirement where client wanted custom autocomplete lookup so after much searching , We found a way to do this. Steps are as below, Step 1 : Copy your &lt; desired_module &gt; editviewdefs.php file to custom\/modules\/&lt; desired_module &gt;\/metadata\/editviewdefs.php Step 2 : Add the JavaScript file you want to include into the location [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-02T16:35:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:23:10+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/\",\"name\":\"custom autocomplete lookup on related field - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2019-10-02T16:35:32+00:00\",\"dateModified\":\"2020-09-08T09:23:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"custom autocomplete lookup on related field\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"custom autocomplete lookup on related field - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/","og_locale":"en_US","og_type":"article","og_title":"custom autocomplete lookup on related field - TechCRM","og_description":"We came across a requirement where client wanted custom autocomplete lookup so after much searching , We found a way to do this. Steps are as below, Step 1 : Copy your &lt; desired_module &gt; editviewdefs.php file to custom\/modules\/&lt; desired_module &gt;\/metadata\/editviewdefs.php Step 2 : Add the JavaScript file you want to include into the location [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/","og_site_name":"TechCRM","article_published_time":"2019-10-02T16:35:32+00:00","article_modified_time":"2020-09-08T09:23:10+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/","url":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/","name":"custom autocomplete lookup on related field - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2019-10-02T16:35:32+00:00","dateModified":"2020-09-08T09:23:10+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/custom-autocomplete-lookup-on-related-field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"custom autocomplete lookup on related field"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":4,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"predecessor-version":[{"id":372,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/203\/revisions\/372"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}