{"id":2132,"date":"2020-02-20T14:59:54","date_gmt":"2020-02-20T19:59:54","guid":{"rendered":"https:\/\/xlinesoft.com\/blog\/?p=2132"},"modified":"2020-02-20T15:08:35","modified_gmt":"2020-02-20T20:08:35","slug":"autofill-based-on-two-fields-selection","status":"publish","type":"post","link":"https:\/\/xlinesoft.com\/blog\/2020\/02\/20\/autofill-based-on-two-fields-selection\/","title":{"rendered":"Autofill based on two fields selection"},"content":{"rendered":"<p>Autofill is a handy feature that allows quickly fill multiple fields after lookup wizard selection. However, it only works based on a single lookup wizard selection. In this article, we will show a more advanced example of implementing a custom Autofill based on two field selection. <\/p>\n<p><strong>field1<\/strong> &#8211; first lookup wizard<br \/>\n<strong>field2<\/strong> &#8211; second lookup wizard<br \/>\n<strong>field3<\/strong> &#8211; field to be filled after field2 selection<br \/>\n<strong>table1<\/strong> &#8211; lookup table where autofill data is coming from<\/p>\n<p>Create a field event based on &#8216;editing&#8217; for field2.<\/p>\n<p><a href=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/02\/scr-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/02\/scr-1-300x242.png\" alt=\"\" width=\"300\" height=\"242\" class=\"alignnone size-medium wp-image-2137\" srcset=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/02\/scr-1-300x242.png 300w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/02\/scr-1-768x618.png 768w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/02\/scr-1.png 867w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<!--more--><\/p>\n<h4>ClientBefore code<\/h4>\n<pre name=\"code\" class=\"javascript:nocontrols\">\r\nvar field1 = ctrl.getPeer('field1');\r\nvar field2 = ctrl.getPeer('field2');\r\nparams[\"field1\"] = field1.getValue();\r\nparams[\"field2\"] = field2.getValue();\r\n<\/pre>\n<h4>Server event<\/h4>\n<p><strong>PHP code<\/strong><\/p>\n<pre name=\"code\" class=\"php:nocontrols\">\r\n$result[\"field3\"] = DBLookup(\"SELECT field3 from table1 where field1 = \".$params[\"field1\"].\" AND field2 = \".$params[\"field2\"]);\r\n<\/pre>\n<p><strong>C# code<\/strong><\/p>\n<pre name=\"code\" class=\"csharp:nocontrols\">\r\ndynamic result = XVar.Array();\r\nresult.InitAndSetArrayItem(tDAL.DBLookup(MVCFunctions.Concat(\"SELECT field3 from table1 where field1 = \", params[\"field1\"], \" AND field2 = \", params[\"field2\"])), \"field3\");\r\n<\/pre>\n<h4>ClientAfter code<\/h4>\n<pre name=\"code\" class=\"javascript:nocontrols\">\r\nvar field3 = ctrl.getPeer('field3');\r\nfield3.setValue(result[\"field3\"]);\r\n<\/pre>\n<p>More info about field events:<br \/>\n<a href=\"https:\/\/xlinesoft.com\/phprunner\/docs\/field_events.htm\">PHPRunner<\/a><br \/>\n<a href=\"https:\/\/xlinesoft.com\/asprunnernet\/docs\/field_events.htm\">ASPRunner.NET<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Autofill is a handy feature that allows quickly fill multiple fields after lookup wizard selection. However, it only works based on a single lookup wizard selection. In this article, we will show a more advanced example of implementing a custom Autofill based on two field selection. field1 &#8211; first lookup wizard field2 &#8211; second lookup wizard field3 &#8211; field to be filled after field2 selection table1 &#8211; lookup table where autofill data is coming from Create a field event based on &#8216;editing&#8217; for field2.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2132","post","type-post","status-publish","format-standard","hentry","category-php-category"],"_links":{"self":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/comments?post=2132"}],"version-history":[{"count":6,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2132\/revisions"}],"predecessor-version":[{"id":2139,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2132\/revisions\/2139"}],"wp:attachment":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/media?parent=2132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/categories?post=2132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/tags?post=2132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}