{"id":158,"date":"2012-04-30T22:53:50","date_gmt":"2012-04-30T16:53:50","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=158"},"modified":"2012-04-30T22:53:50","modified_gmt":"2012-04-30T16:53:50","slug":"populating-notes-field-from-cascading-dropdown-selections","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=158","title":{"rendered":"Populating Notes field from Cascading Dropdown Selections"},"content":{"rendered":"<p>This was a solution I figured out for populating a notes field from <a href=\"http:\/\/spservices.codeplex.com\/discussions\/78100#post830254\">cascading drop-downs<\/a>. I&#8217;ve had some folks e-mail me asking for the actual implementation.<\/p>\n<p>In my scenario, I was creating a Sharepoint form front-end that would create an Incident Ticket in BMC Remedy.<\/p>\n<p><a href=\"http:\/\/markwheeler.com\/wordpress\/wp-content\/uploads\/2012\/04\/rc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-159\" title=\"rc\" src=\"http:\/\/markwheeler.com\/wordpress\/wp-content\/uploads\/2012\/04\/rc.png\" alt=\"\" width=\"621\" height=\"438\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Here\u2019s what I did.<\/p>\n<p>1. Created an initial Sharepoint list (this was for the first drop-down) where a user selected a top-level category for tech help.\u00a0This was a one colum list with just &#8220;Title&#8221; that looked like this:<\/p>\n<p>Hardware Failure<br \/>\nInstall Software<br \/>\nPassword Reset<br \/>\nService Request<\/p>\n<p>2. Created a second Sharepoint list (this was for the second drop-down) Based on the selection above, I display sub-categories.\u00a0This list had 2 columns; Title, SumCat. SumCat matches Title from 1<sup>st<\/sup> list.<\/p>\n<p>So based on above it looked like this:<\/p>\n<p>Audio Conference Request, Service Request<br \/>\nVideo Conference Request, Service Request<br \/>\nPC Bluescreen, Hardware Failure<br \/>\nBlackberry Broken, Hardware Failure<\/p>\n<p>3. Created a third Sharepoint list (this is what populates the Notes field). Based on second-drop down, look up questions to help a tech know what the problem is.<\/p>\n<p>This had two columns, Title, Body. Title matches Title column in 2<sup>nd<\/sup> list.<\/p>\n<p>For example:<\/p>\n<p>Audio Conference Request, then the Body column had this text.<br \/>\nConference Name:<br \/>\nHost Name:<br \/>\nHost Phone:<br \/>\nDate:<br \/>\nDuration:<br \/>\n# of lines:<\/p>\n<p>When the notes field is populated; users would enter the relevant information: See screenshot above.<\/p>\n<p>4. Created a 4<sup>th<\/sup> Sharepoint list that holds the actual requests.<\/p>\n<p>The columns are Category (lookup on 1<sup>st<\/sup> list), Summary (lookup on 2<sup>nd<\/sup> list), Notes (Multiple lines of text), OtherID (person or group).<\/p>\n<p>Here&#8217;s the script; this was placed under PlaceHolderMain on the NewForm.aspx<\/p>\n<p>&lt;script language=&#8221;javascript&#8221; type=&#8221;text\/javascript&#8221; src=&#8221;jquery.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script language=&#8221;javascript&#8221; type=&#8221;text\/javascript&#8221; src=&#8221;jquery.SPServices-0.5.4.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221; language=&#8221;javascript&#8221;&gt;<\/p>\n<p>$(document).ready(function() {<br \/>\n\/\/ alert(&#8216;Working!&#8217;);<\/p>\n<p>$().SPServices.SPCascadeDropdowns({<br \/>\nrelationshipList: &#8220;RC_Summary&#8221;,<br \/>\nrelationshipListParentColumn: &#8220;SumCat&#8221;,<br \/>\nrelationshipListChildColumn: &#8220;Title&#8221;,<br \/>\nparentColumn: &#8220;Category&#8221;,<br \/>\nchildColumn: &#8220;Summary&#8221;,<br \/>\ndebug: true<\/p>\n<p>});<\/p>\n<p>$().SPServices.SPDisplayRelatedInfo({<br \/>\ncolumnName: &#8220;Summary&#8221;,<br \/>\nrelatedList: &#8220;RC_Notes&#8221;,<br \/>\nrelatedListColumn: &#8220;Title&#8221;,<br \/>\nrelatedColumns: [&#8220;Body&#8221;],<br \/>\ndisplayFormat: &#8220;notes&#8221;,<br \/>\nchildColumn: &#8220;Notes&#8221;,<br \/>\ndebug: true<br \/>\n});<\/p>\n<p>});<br \/>\n&lt;\/script&gt;<br \/>\n&lt;script language=&#8221;javascript&#8221; type=&#8221;text\/javascript&#8221; &gt;<br \/>\nfunction PreSaveAction() {<br \/>\n\/\/ alert(&#8220;PreSave&#8221;);<br \/>\n$(&#8220;input[name^=&#8217;fileupload&#8217;]&#8221;).each(function() {<br \/>\nif ($(this).val() != &#8220;&#8221;) {<br \/>\n\/\/ alert($(this).val());<br \/>\nvar fpath = $(this).val();<br \/>\nvar m = fpath.match(\/(.*)[\/\\]([^\/\\]+.w+)$\/);<\/p>\n<p>\/\/ alert(m[2]);<\/p>\n<p>$().SPServices({<br \/>\noperation: &#8220;UpdateListItems&#8221;,<br \/>\nasync: false,<br \/>\nlistName: &#8220;WorkInfo&#8221;,<br \/>\nupdates: &#8220;&lt;Batch OnError=&#8217;Continue&#8217; PreCalc=&#8217;TRUE&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;Method ID=&#8217;1&#8242; Cmd=&#8217;New&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;Field Name=&#8217;Title&#8217;&gt;&#8221; + m[2] + &#8220;&lt;\/Field&gt;&#8221; +<br \/>\n&#8220;&lt;\/Method&gt;&#8221; +<br \/>\n&#8220;&lt;\/Batch&gt;&#8221;,<br \/>\ncompletefunc: function(xData, Status) {<br \/>\n\/\/ alert(&#8220;Status=&#8221; + Status + &#8221; XML=&#8221; + xData.responseXML.xml);<br \/>\n}<br \/>\n});<br \/>\n\/\/ return true;<\/p>\n<p>}<br \/>\n});<br \/>\nreturn true;<br \/>\n}&lt;\/script&gt;<\/p>\n<p>I also created a new &#8216;CASE&#8217; for SPDisplayRelatedInfo for the SPServices library. Note: This is hardcoded to look for a multiline textbox named &#8220;Notes&#8221;<\/p>\n<p>\/\/ append to Notes field<br \/>\ncase &#8220;notes&#8221;:<br \/>\nvar outString = &#8220;Please provide supporting information:&#8221;; \/\/ This does display on page load<br \/>\n\/\/ Get relevant Notes from relatedlist<\/p>\n<p>for (i=0; i &lt; opt.relatedColumns.length; i++) {<br \/>\n$(xData.responseXML).find(&#8220;[nodeName=z:row]&#8221;).each(function() {<\/p>\n<p>\/\/\u00a0outString += &#8220;* &#8221; + relatedColumnsXML[i].attr(&#8220;DisplayName&#8221;) + &#8221; *&#8221;;<br \/>\noutString += &#8220;* &#8221; + showColumn(relatedColumnsXML[i], $(this).attr(&#8220;ows_&#8221; + opt.relatedColumns[i]), opt) + &#8221; *&#8221;;<\/p>\n<p>});<br \/>\n}<\/p>\n<p>\/\/ alert(outString); Debugging<\/p>\n<p>setTextFromFieldName(&#8220;Notes&#8221;, &#8220;&#8221; + outString + &#8220;&#8221;);<\/p>\n<p>break;<\/p>\n<p>\/\/ end of new &#8216;CASE&#8217;<\/p>\n<p>At the end of the jquery.SPServices.js, I have added the following functions:<\/p>\n<p>\/\/ Find the Notes field<br \/>\nfunction setTextFromFieldName(fieldName, value) {<br \/>\nif (value == undefined) return;<br \/>\n\/\/ alert(value);<br \/>\nvar theTextBox = getTagFromIdentifierAndTitle(&#8220;textarea&#8221;,&#8221;&#8221;,fieldName);theTextBox.value=value<br \/>\n}<\/p>\n<p>function getTagFromIdentifierAndTitle(tagName, identifier, title) {<\/p>\n<p>var len = identifier.length;<\/p>\n<p>var tags = document.getElementsByTagName(tagName);<\/p>\n<p>for (var i=0; i &lt; tags.length; i++) {<\/p>\n<p>var tempString = tags[i].id;<\/p>\n<p>if (tags[i].title == title &amp;&amp; (identifier == &#8220;&#8221; || tempString.indexOf(identifier) == tempString.length &#8211; len)) {<\/p>\n<p>return tags[i];<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>return null;<\/p>\n<p>}<\/p>\n<p>\/\/ End of new functions<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This was a solution I figured out for populating a notes field from cascading drop-downs. I&#8217;ve had some folks e-mail me asking for the actual implementation. In my scenario, I was creating a Sharepoint form front-end that would create an Incident Ticket in BMC Remedy. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[30,32],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-bmc-remedy","tag-cascading-drop-downs"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}