{"id":920,"date":"2015-07-10T11:44:51","date_gmt":"2015-07-10T18:44:51","guid":{"rendered":"http:\/\/somethingk.com\/main\/?p=920"},"modified":"2017-03-03T09:24:31","modified_gmt":"2017-03-03T16:24:31","slug":"creating-a-sharepoint-like-through-soap-requests","status":"publish","type":"post","link":"https:\/\/somethingk.com\/main\/creating-a-sharepoint-like-through-soap-requests\/","title":{"rendered":"Creating a Sharepoint &#8216;Like&#8217; through SOAP Requests"},"content":{"rendered":"<p>Sharepoint is not my most favorite environment to program in but I figure I&#8217;d share a cool javascript app I put together that communicates with Sharepoint&#8217;s SOAP API to add on to\u00a0custom &#8216;like&#8217; buttons (just like facebook!) With this feature, users can &#8216;like&#8217; sharepoint items without going through the crazy sharepoint interface. This javascript can be added to a web interface, and users can &#8216;like&#8217; items from there!<\/p>\n<figure id=\"attachment_921\" aria-describedby=\"caption-attachment-921\" style=\"width: 246px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/somethingk.com\/main\/wp-content\/uploads\/2015\/07\/Capture.png\"><img decoding=\"async\" class=\"size-full wp-image-921\" src=\"http:\/\/somethingk.com\/main\/wp-content\/uploads\/2015\/07\/Capture.png\" alt=\"None of this garbage\" width=\"246\" height=\"111\" \/><\/a><figcaption id=\"caption-attachment-921\" class=\"wp-caption-text\">None of this garbage<\/figcaption><\/figure>\n<p>I wrote some javascript\/jquery code that can easily retrieve the number of \u2018likes\u2019 for a sharepoint list item or list. The script basically queries Sharepoint\u2019s built in social services for the tag count with SOAP POST calls.<\/p>\n<h3>Get Like Count<\/h3>\n<p><strong>Here is the script to get &#8216;like&#8217; count:<\/strong><\/p>\n<hr \/>\n<div class=\"snippetcpt-wrap\" id=\"snippet-960\" data-id=\"960\" data-edit=\"\" data-copy=\"\/main\/wp-json\/wp\/v2\/posts\/920?snippet=17b1fac833&#038;id=960\" data-fullscreen=\"https:\/\/somethingk.com\/main\/code-snippets\/get-like-count\/?full-screen=1\">\n\t\t\t\t<pre class=\"prettyprint linenums lang-javascript\" title=\"Get Like Count\">&lt;script&gt;\r\n\r\nfunction GetLikeCountFromService(strURL) {\r\n\r\nvar count = 0;\r\n\r\n\/\/change the webMethod var to match up to the correct sharepoint _vti_bin location. (https:\/\/msdn.microsoft.com\/en-us\/library\/office\/Bb862916(v=office.12).aspx)\r\n\r\nvar webMethod = \\'\/_vti_bin\/SocialDataService.asmx?op=GetTagTermsOnUrl\\';\r\n\r\nvar soapEnv = &quot;&lt;soap:Envelope xmlns:xsi=\\'http:\/\/www.w3.org\/2001\/XMLSchema-instance\\' xmlns:xsd=\\'http:\/\/www.w3.org\/2001\/XMLSchema\\' xmlns:soap=\\'http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\\'&gt; &lt;soap:Body&gt;&lt;GetTagTermsOnUrl xmlns=\\'http:\/\/microsoft.com\/webservices\/SharePointPortalServer\/SocialDataService\\'&gt; &lt;url&gt;&quot; + strURL + &quot;&lt;\/url&gt; &lt;maximumItemsToReturn&gt;1&lt;\/maximumItemsToReturn&gt; &lt;\/GetTagTermsOnUrl&gt; &lt;\/soap:Body&gt; &lt;\/soap:Envelope&gt;&quot;;\r\n\r\n\r\n\r\n$.ajax({\r\n\r\ntype: &quot;POST&quot;,\r\n\r\nasync: true,\r\n\r\nurl: webMethod,\r\n\r\ndata: soapEnv,\r\n\r\ncontentType: &quot;text\/xml; charset=utf-8&quot;,\r\n\r\ndataType: &quot;xml&quot;,\r\n\r\nsuccess: function(data, textStatus, XMLHttpRequest) {\r\n\r\ncount&nbsp; = $(\\'SocialTermDetail\\', data).find(\\'Count\\').text();\r\n\r\n}\r\n\r\n});\r\n\r\nreturn count;\r\n\r\n}\r\n\r\n&lt;\/script&gt;<\/pre>\n\t\t\t<\/div>\n<hr \/>\n<p><strong>Called by:<\/strong> GetLikeCountFromService(&#8216;&lt;LIST OR LIST ITEM URL&gt;&#8217;)<\/p>\n<p><strong>Example:<\/strong> GetLikeCountFromService(&#8216;http:\/\/mysharepoint\/list\/item&#8217;)<\/p>\n<p>Here is the script to post \u2018likes\u2019 to an article. Once again it\u2019s a nice javascript that can put into an HTML\u00a0header or what not.<\/p>\n<h3>Emulate a &#8216;like&#8217;<\/h3>\n<p><strong>Script to post a &#8216;like&#8217;:<\/strong><\/p>\n<hr \/>\n<div class=\"snippetcpt-wrap\" id=\"snippet-961\" data-id=\"961\" data-edit=\"\" data-copy=\"\/main\/wp-json\/wp\/v2\/posts\/920?snippet=17b1fac833&#038;id=961\" data-fullscreen=\"https:\/\/somethingk.com\/main\/code-snippets\/emulate-a-like\/?full-screen=1\">\n\t\t\t\t<pre class=\"prettyprint linenums lang-javascript\" title=\"Emulate a \\&#039;Like\\&#039;\">function AddLikeCountFromService(strURL) {\r\n\r\n\/\/change the webMethod var to match up to the correct sharepoint _vti_bin location. (https:\/\/msdn.microsoft.com\/en-us\/library\/office\/Bb862916(v=office.12).aspx)\r\n\r\nvar webMethod = \\'\/_vti_bin\/SocialDataService.asmx?op=GetAllTagTermsForUrlFolder\\';\r\n\r\nvar soapEnv = &quot;&lt;soap:Envelope xmlns:xsi=\\'http:\/\/www.w3.org\/2001\/XMLSchema-instance\\' xmlns:xsd=\\'http:\/\/www.w3.org\/2001\/XMLSchema\\' xmlns:soap=\\'http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\\'&gt;&lt;soap:Body&gt;&lt;GetAllTagTermsForUrlFolder xmlns=\\'http:\/\/microsoft.com\/webservices\/SharePointPortalServer\/SocialDataService\\'&gt;&lt;urlFolder&gt;&quot;+strURL+&quot;&lt;\/urlFolder&gt;&lt;maximumItemsToReturn&gt;1&lt;\/maximumItemsToReturn&gt;&lt;\/GetAllTagTermsForUrlFolder&gt;&lt;\/soap:Body&gt;&lt;\/soap:Envelope&gt;&quot;;\r\n\r\n$.ajax({\r\n\r\ntype: &quot;POST&quot;,\r\n\r\nasync: true,\r\n\r\nurl: webMethod,\r\n\r\ndata: soapEnv,\r\n\r\ncontentType: &quot;text\/xml; charset=utf-8&quot;,\r\n\r\ndataType: &quot;xml&quot;,\r\n\r\nsuccess: function(data, textStatus, XMLHttpRequest) {\r\n\r\nvar info&nbsp; = ($(\\'SocialTermDetail\\', data).text()).split(&quot; &quot;);\r\n\r\nvar guid = (info[0]).substring(0, info[0].length - 1);\r\n\r\n\/\/change the webMethod var to match up to the correct sharepoint _vti_bin location. (https:\/\/msdn.microsoft.com\/en-us\/library\/office\/Bb862916(v=office.12).aspx)\r\n\r\nwebMethod = \\'\/_vti_bin\/SocialDataService.asmx?op=AddTag\\';\r\n\r\n\/\/In the soapEnv request, you can change the title field to anything. This is the title of the thing the user is liking.\r\n\r\nsoapEnv = &quot;&lt;soap:Envelope xmlns:xsi=\\'http:\/\/www.w3.org\/2001\/XMLSchema-instance\\' xmlns:xsd=\\'http:\/\/www.w3.org\/2001\/XMLSchema\\' xmlns:soap=\\'http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\\'&gt; &lt;soap:Body&gt;&lt;AddTag xmlns=\\'http:\/\/microsoft.com\/webservices\/SharePointPortalServer\/SocialDataService\\'&gt;&lt;url&gt;&quot;+strURL+&quot;&lt;\/url&gt;&lt;termID&gt;&quot;+guid+&quot;&lt;\/termID&gt;&lt;title&gt;I like it!&lt;\/title&gt;&lt;isPrivate&gt;false&lt;\/isPrivate&gt;&lt;\/AddTag&gt;&lt;\/soap:Body&gt; &lt;\/soap:Envelope&gt;&quot;;\r\n\r\n$.ajax({\r\n\r\ntype: &quot;POST&quot;,\r\n\r\nasync: true,\r\n\r\nurl: webMethod,\r\n\r\ndata: soapEnv,\r\n\r\ncontentType: &quot;text\/xml; charset=utf-8&quot;,\r\n\r\ndataType: &quot;xml&quot;,\r\n\r\nsuccess: function(data, textStatus, XMLHttpRequest) {\r\n\r\n}\r\n\r\n});\r\n\r\n}\r\n\r\n});<\/pre>\n\t\t\t<\/div>\n<hr \/>\n<p>Called By:<\/p>\n<p><strong>Example: <\/strong>AddLikeCountFromService(&#8216;&lt;LIST OR LIST ITEM URL&gt;&#8217;)<\/p>\n<p>AddLikeCountFromService(&#8216;http:\/\/mysharepoint\/list\/item&#8217;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sharepoint is not my most favorite environment to program in but I figure I&#8217;d share a cool javascript app I put together that communicates with Sharepoint&#8217;s SOAP API to add on to\u00a0custom &#8216;like&#8217; buttons (just like facebook!) With this feature, users can &#8216;like&#8217; sharepoint items without going through the crazy sharepoint interface. This javascript can be added to a web [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[177,322],"tags":[330,329,325,323,324,328,327,326],"class_list":["post-920","post","type-post","status-publish","format-standard","hentry","category-development","category-web","tag-button","tag-custom","tag-html","tag-javascript","tag-jquery","tag-like","tag-sharepoint","tag-soap"],"_links":{"self":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/comments?post=920"}],"version-history":[{"count":10,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/920\/revisions"}],"predecessor-version":[{"id":964,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/920\/revisions\/964"}],"wp:attachment":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/media?parent=920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/categories?post=920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/tags?post=920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}