<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>javascript Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/tag/javascript/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 10 Jan 2019 12:46:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>SharePoint Online &#8211; Internal Fields Names &#038; how to use SPServices to get them!!!</title>
		<link>https://blogit.create.pt/fabiocarvalho/2017/05/26/sharepoint-online-internal-fields-names-how-to-use-spservices-to-get-them/</link>
					<comments>https://blogit.create.pt/fabiocarvalho/2017/05/26/sharepoint-online-internal-fields-names-how-to-use-spservices-to-get-them/#comments</comments>
		
		<dc:creator><![CDATA[Fábio Carvalho]]></dc:creator>
		<pubDate>Fri, 26 May 2017 08:57:06 +0000</pubDate>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[CSOM]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[SharePoint 2016]]></category>
		<category><![CDATA[SharePoint Online]]></category>
		<category><![CDATA[SPServices]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/fabiocarvalho/?p=3204</guid>

					<description><![CDATA[<p>Hi Everyone, Today i will show you how can you get internal field names in a SharePoint List Items. As you know SharePoint have two types of Names &#8211; Internal Name and Display Name, it is extremity important when you are developing SharePoint solution get your fields by internal name, the InternalName never changes, you [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/fabiocarvalho/2017/05/26/sharepoint-online-internal-fields-names-how-to-use-spservices-to-get-them/">SharePoint Online &#8211; Internal Fields Names &#038; how to use SPServices to get them!!!</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi Everyone,</p>
<p>Today i will show you how can you get <strong>internal field</strong> names in a<strong> SharePoint List Items</strong>.<br />
As you know SharePoint have<strong> two types</strong> of Names &#8211; <strong>Internal</strong> <strong>Name</strong> and <strong>Display</strong> <strong>Name</strong>, it is extremity important when you are developing SharePoint solution get your fields by internal name, the <strong>InternalName</strong> never changes, you only can change <strong>DisplayName</strong>, this maintain your <strong>solution stable</strong>.</p>
<p>So let&#8217;s Look some ways to get the I<strong>nternal Name</strong>:</p>
<ol>
<li>Open the List Settings page</li>
<li>Under the Columns section, select a column to view the Edit Column page</li>
<li>The URL of this page includes the internal name in the query string. For example, the URL for the <span style="color: #800000"><strong><tt>Created By</tt></strong></span> field includes the following query string <strong><tt>List=%7BF641CEF1%2DCDE2%2D49E1%2D9800%2D861A408EF890%7D&amp;Field=<span style="color: #800000">Author</span></tt></strong>. The value for the Field parameter, <strong><span style="color: #800000"><tt>Author</tt></span></strong>, is the internal name for<span style="color: #800000"><strong> <tt>Created By</tt></strong></span>.</li>
</ol>
<p>You can also apply a sort order on your list view on the column that you want get the internal name, this will generate an URL that contains the <span style="color: #800000"><strong>Internal Name</strong></span>:</p>
<p><strong>FolderCTID%3D0x012000DDDEBA09D4201845A62AEDBA6A906745-SortField%3D<span style="color: #800000">Author</span>-SortDir%3DAsc-</strong></p>
<p>Now i will demonstrate how you can get Internal Name by Display Name using <span style="color: #800000"><a style="color: #800000" href="https://spservices.codeplex.com/wikipage?title=$().SPServices.SPGetStaticFromDisplay&amp;referringTitle=Documentation" target="_blank" rel="noopener noreferrer">SPGetStaticFromDisplay</a></span></p>
<pre class="brush: jscript; title: ; notranslate"> 

var internalName = $().SPServices.SPGetStaticFromDisplay ({
  listName: &quot;Cars&quot;,
  columnDisplayName: &quot;Car Models&quot;
});

</pre>
<p><strong>Read more</strong>: http://sympmarc.com/2015/01/27/get-the-internalname-for-a-sharepoint-list-column/</p>
<p>Thanks</p>
<p><span style="color: #000000"><a style="color: #000000" href="https://www.linkedin.com/in/fmrgc/"><strong>Fábio Carvalho</strong></a></span><br />
SharePoint Consultant<br />
<strong>|create|</strong><span style="color: #ff0000"><strong>it</strong></span><strong>|</strong></p>
<p>&nbsp;</p>
<p>The post <a href="https://blogit.create.pt/fabiocarvalho/2017/05/26/sharepoint-online-internal-fields-names-how-to-use-spservices-to-get-them/">SharePoint Online &#8211; Internal Fields Names &#038; how to use SPServices to get them!!!</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/fabiocarvalho/2017/05/26/sharepoint-online-internal-fields-names-how-to-use-spservices-to-get-them/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SharePoint Online, 2013 and 2016 &#8211; Display list data in grid using Rest API</title>
		<link>https://blogit.create.pt/fabiocarvalho/2017/02/08/sharepoint-online-2013-and-2016-display-list-data-in-grid-using-rest-api/</link>
					<comments>https://blogit.create.pt/fabiocarvalho/2017/02/08/sharepoint-online-2013-and-2016-display-list-data-in-grid-using-rest-api/#comments</comments>
		
		<dc:creator><![CDATA[Fábio Carvalho]]></dc:creator>
		<pubDate>Wed, 08 Feb 2017 02:12:14 +0000</pubDate>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[SharePoint 2016]]></category>
		<category><![CDATA[SharePoint Online]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/fabiocarvalho/?p=401</guid>

					<description><![CDATA[<p>Hey Everyone! Today, in this post i will show you how can we display list data in a grid using Rest API in SharePoint Online, 2013 and 2016. In this example, i will create a table &#8211; Cars &#8211; with 4 columns: &#8211; Make &#8211; Model &#8211; Price &#8211; Color &#60;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&#62;&#60;/script&#62; &#60;script&#62; $(function(){ $("#btnClick").click(function(){ [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/fabiocarvalho/2017/02/08/sharepoint-online-2013-and-2016-display-list-data-in-grid-using-rest-api/">SharePoint Online, 2013 and 2016 &#8211; Display list data in grid using Rest API</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hey Everyone!</p>
<p>Today, in this post i will show you how can we display list data in a grid using <strong>Rest API</strong> in <strong>SharePoint Online, 2013 and 2016.</strong><br />
In this example, i will create a table &#8211; Cars &#8211; with 4 columns:</p>
<p>&#8211; Make<br />
&#8211; Model<br />
&#8211; Price<br />
&#8211; Color</p>
<pre>&lt;script src="<span style="color: #993300">https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js</span>"&gt;&lt;/script&gt;
&lt;script&gt;
$(<span style="color: #0000ff">function</span>(){
    $("<span style="color: #993300">#btnClick</span>").click(<span style="color: #0000ff">function</span>(){
        <span style="color: #0000ff">var</span> requestUri = _spPageContextInfo.webAbsoluteUrl + <span style="color: #993300">"/_api/web/lists/getbytitle('Cars')/items"</span>;
           $.ajax({
              url: requestUri,
              type: "<span style="color: #993300">GET</span>",
              headers: {
                  <span style="color: #993300">"accept":"application/json; odata=verbose"</span>
              },
              success: onSuccess,
              error: onError
});

<span style="color: #0000ff">  function</span> onSuccess(data) {
     <span style="color: #0000ff">var</span> objItems = data.d.results;
<span style="color: #0000ff">     var</span> tableContent = <span style="color: #993300">'&lt;table id="tableCars" style="width:100%" border="1 px"&gt;&lt;thead&gt;&lt;tr&gt;&lt;td&gt;Make&lt;/td&gt;'</span> + <span style="color: #993300">'&lt;td&gt;Model&lt;/td&gt;'</span> + <span style="color: #993300">'&lt;td&gt;Price&lt;/td&gt;'</span> + <span style="color: #993300">'&lt;td&gt;Color&lt;/td&gt;'</span> + <span style="color: #993300">'&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;'</span>;
  
<span style="color: #0000ff">     for</span> (<span style="color: #0000ff">var</span> i = 0; i &lt; objItems.length; i++) {
         tableContent += <span style="color: #993300">'&lt;tr&gt;'</span>;
         tableContent += <span style="color: #993300">'&lt;td&gt;'</span> + objItems[i].Make  + <span style="color: #993300">'&lt;/td&gt;'</span>;
         tableContent += <span style="color: #993300">'&lt;td&gt;'</span> + objItems[i].Model +<span style="color: #993300"> '&lt;/td&gt;'</span>;
         tableContent += <span style="color: #993300">'&lt;td&gt;'</span> + objItems[i].Price + <span style="color: #993300">'&lt;/td&gt;'</span>;
         tableContent += <span style="color: #993300">'&lt;td&gt;'</span> + objItems[i].Color + <span style="color: #993300">'&lt;/td&gt;'</span>;
         tableContent += <span style="color: #993300">'&lt;/tr&gt;'</span>;
 }
   $(<span style="color: #993300">'#carsGrid'</span>).append(tableContent);
   }
<span style="color: #0000ff">    function</span> onError(error) {
        alert(<span style="color: #993300">'Error'</span>);
   }
  });
});

&lt;/script&gt;
&lt;input type="<span style="color: #993300">button</span>" id="<span style="color: #993300">btnClick</span>" value="<span style="color: #993300">Get All Cars</span>"/&gt;
&lt;div id="<span style="color: #993300">CustomerPanel</span>"&gt;
   &lt;table id='<span style="color: #993300">tableCars</span>' style="<span style="color: #993300">width: 100%;</span>" border="<span style="color: #993300">1 px</span>"&gt;
     &lt;tr&gt;
       &lt;td&gt;
          &lt;div id="<span style="color: #993300">carsGrid</span>" style="<span style="color: #993300">width: 100%</span>"&gt;&lt;/div&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
 &lt;/table&gt;
&lt;/div&gt;</pre>
<p>You just need to copy the code and past in a<strong> script editor webpart</strong>, if you press the button  &#8211; Get All Cars &#8211;  the result it&#8217;s a the following table:</p>
<table border="0" width="400" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="100">Mark</td>
<td valign="top" width="100">Model</td>
<td valign="top" width="100">Price</td>
<td valign="top" width="100">Color</td>
</tr>
<tr>
<td valign="top" width="100">Mercedes</td>
<td valign="top" width="100">A180</td>
<td valign="top" width="100">22.000.00€</td>
<td valign="top" width="100">Red</td>
</tr>
<tr>
<td valign="top" width="100">Jaguar</td>
<td valign="top" width="100">X-Type</td>
<td valign="top" width="100">72.000.00€</td>
<td valign="top" width="100">Green</td>
</tr>
<tr>
<td valign="top" width="100">Fiat</td>
<td valign="top" width="100">500</td>
<td valign="top" width="100">20.000.00€</td>
<td valign="top" width="100">Blue</td>
</tr>
<tr>
<td valign="top" width="100">Bmw</td>
<td valign="top" width="100">320d</td>
<td valign="top" width="100">32.000.00€</td>
<td valign="top" width="100">Black</td>
</tr>
</tbody>
</table>
<p>If you are interested to read more, i recommend the following links:<br />
<a href="https://msdn.microsoft.com/en-us/library/office/jj860569.aspx">https://msdn.microsoft.com/en-us/library/office/jj860569.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/office/jj164022.aspx">https://msdn.microsoft.com/en-us/library/office/jj164022.aspx</a></p>
<p>Thanks</p>
<p><strong>Fábio Carvalho</strong><br />
SharePoint Consultant<br />
<strong>|create|</strong><span style="color: #ff0000"><strong>it</strong></span><strong>|</strong></p>
<p>The post <a href="https://blogit.create.pt/fabiocarvalho/2017/02/08/sharepoint-online-2013-and-2016-display-list-data-in-grid-using-rest-api/">SharePoint Online, 2013 and 2016 &#8211; Display list data in grid using Rest API</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/fabiocarvalho/2017/02/08/sharepoint-online-2013-and-2016-display-list-data-in-grid-using-rest-api/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>How to log knockout.js errors</title>
		<link>https://blogit.create.pt/joaopais/2016/11/29/how-to-log-knockout-js-errors/</link>
					<comments>https://blogit.create.pt/joaopais/2016/11/29/how-to-log-knockout-js-errors/#comments</comments>
		
		<dc:creator><![CDATA[João Pais]]></dc:creator>
		<pubDate>Tue, 29 Nov 2016 17:52:09 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Custom Binding Provider]]></category>
		<category><![CDATA[Custom Error Handler]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Knockout]]></category>
		<category><![CDATA[knockout.js]]></category>
		<category><![CDATA[Log]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/joaopais/?p=461</guid>

					<description><![CDATA[<p>How to log knockout.js errors? Right now I&#8217;m working in a banking area project. It&#8217;s a web project and we are using Knockout.JS framework. We (developers) don&#8217;t have access to the project front-end in Production Environment. On the server side we log all errors and debug information into a table in our database. Yes, we [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/joaopais/2016/11/29/how-to-log-knockout-js-errors/">How to log knockout.js errors</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>How to log knockout.js errors?</p>
<p>Right now I&#8217;m working in a banking area project. It&#8217;s a web project and we are using Knockout.JS framework.<br />
We (developers) don&#8217;t have access to the project front-end in Production Environment. On the server side we log all errors and debug information into a table in our database. Yes, we don&#8217;t have access to our project front-end but we are able to consult (and only with read privileges) our database.</p>
<p>So, when happens a client side error in Production Environment, it&#8217;s pretty hard to figure out what&#8217;s wrong. All we have is a printscreen from the user.</p>
<p>Sometimes it&#8217;s impossible to reproduce the Production Environment error because all the development environments (LOC-DEV-STA-PRE) have different data information and different code versions with different develepments in comparison with Production Environment. So, we really need to get detailed information about client-side errors.</p>
<p>In this post, I&#8217;m going to show you how to log <strong>only</strong> Knockout.JS errors. So, general javascript errors will not be discussed here.</p>
<p>First of all, we need to write an Error Handling Binding Provider. For more information about Custom Bindings Providers please read this <a target="_blank" href="http://www.knockmeout.net/2011/09/ko-13-preview-part-2-custom-binding.html">blog post</a>. Please be carefull because something may have changed because it&#8217;s based on an old knockout.JS version).</p>
<pre class="brush: jscript; title: ; notranslate">

// Custom Error Handler.
var MyErrorBindingProvider = function () {

	// Create a binding provider.
    var original = new ko.bindingProvider();

    // check if the element has bindings
    this.nodeHasBindings = original.nodeHasBindings;

    //return the bindings given a node and the bindingContext
    this.getBindingAccessors = function (node, bindingContext) {
        var result = {};

        // catch syntax errors when parsing binding 
        try {
            result = original.getBindingAccessors(node, bindingContext);
        }
		// Something wrong happened...
        catch (e) {
            // do whatever you want. (alert, debug, console.log, send it to server, etc)			
            if (console &amp;&amp; console.log) {
                console.log(&quot;Error occurred in binding syntax: &quot; + e.message, node);
            }
        }

        // catch errors when evaluating the value of a binding
        ko.utils.objectForEach(result, function (key, value) {
            result&#x5B;key] = function () {
                var result = null;

                try {
                    result = value();
                }
				// Something wrong happened...
                catch (e) {
					// do whatever you want. (alert, debug, console.log, send it to server, etc)
                    if (console &amp;&amp; console.log) {	
                        console.log(&quot;Error occurred in \&quot;&quot; + key + &quot;\&quot; binding: &quot; + e.message, node);
                    }
                }

                return result;
            };
        });
        return result;
    };
};
</pre>
<p>Now that we have our Custom Binding Provider, we need to instantiate it.<br />
Just add it in your document.ready function where you do your applyBindings and etc:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function () {

	// my viewModel
	var viewModel = {
		firstName: ko.observable(&quot;Joao&quot;)
	};
	
	// Error Subscription while observables values changed
     ko.bindingProvider.instance = new MyErrorBindingProvider();
	
	// Apply Bindings.
	ko.applyBindings(viewModel);
});
</pre>
<p>As you have read in the begining of this post, I wrote that we don&#8217;t have access to Production environment, so we sent any knockout error to server side in order to be stored in a database table and then we are able to consult it. This can be done with a simple AJAX call. Just send what it&#8217;s been showed on console.log in this example.</p>
<p>Finally, here you have an HTML sample to try it by yourself:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Knockout.JS Error Handling&lt;/title&gt;

&lt;script type='text/javascript' src='https://code.jquery.com/jquery-3.1.0.min.js'&gt;&lt;/script&gt;
&lt;script type='text/javascript' src='https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.3.0.js'&gt;&lt;/script&gt;
&lt;script type='text/javascript' src='Index.js'&gt;&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;

&lt;div&gt;   
    &lt;p&gt;First name: &lt;input data-bind='textInput: firstName' /&gt;&lt;/p&gt;
	&lt;span&gt;Hello &lt;/span&gt;&lt;span data-bind='text: firstName'&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now, let&#8217;s see the difference between using our error handler and not using it.<br />
For instance, if you forget to close your first data-bind statement:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div&gt;   
    &lt;p&gt;First name: &lt;input data-bind='textInput: firstName /&gt;&lt;/p&gt;
	&lt;span&gt;Hello &lt;/span&gt;&lt;span data-bind='text: firstName'&gt;&lt;/span&gt;
&lt;/div&gt;
</pre>
<p><strong>With </strong>our error handler:<br />
<a target="_blank" href="http://blogit-create.com/wp-content/uploads/2016/11/1.png"><img decoding="async" src="http://blogit-create.com/wp-content/uploads/2016/11/1-300x42.png" alt="1" width="300" height="42" class="alignnone size-medium wp-image-221" /></a></p>
<p><strong>Without </strong>our error handler:<br />
<a target="_blank" href="http://blogit-create.com/wp-content/uploads/2016/11/3.png"><img fetchpriority="high" decoding="async" src="http://blogit-create.com/wp-content/uploads/2016/11/3-300x223.png" alt="3" width="300" height="223" class="alignnone size-medium wp-image-231" srcset="https://blogit.create.pt/wp-content/uploads/2016/11/3-300x223.png 300w, https://blogit.create.pt/wp-content/uploads/2016/11/3-80x60.png 80w, https://blogit.create.pt/wp-content/uploads/2016/11/3-265x198.png 265w, https://blogit.create.pt/wp-content/uploads/2016/11/3-566x420.png 566w, https://blogit.create.pt/wp-content/uploads/2016/11/3.png 567w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>For instance, if you are trying to data-bind an undefined observable:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div&gt;   
    &lt;p&gt;First name: &lt;input data-bind='textInput: firstName' /&gt;&lt;/p&gt;
	&lt;span&gt;Hello &lt;/span&gt;&lt;span data-bind='text: lastName'&gt;&lt;/span&gt;
&lt;/div&gt;
</pre>
<p><strong>With </strong>our error handler:<br />
<a target="_blank" href="http://blogit-create.com/wp-content/uploads/2016/11/2.png"><img decoding="async" src="http://blogit-create.com/wp-content/uploads/2016/11/2-300x24.png" alt="2" width="300" height="24" class="alignnone size-medium wp-image-241" /></a></p>
<p><strong>Without </strong>our error handler:<br />
<a target="_blank" href="http://blogit-create.com/wp-content/uploads/2016/11/4.png"><img decoding="async" src="http://blogit-create.com/wp-content/uploads/2016/11/4-300x212.png" alt="4" width="300" height="212" class="alignnone size-medium wp-image-251" srcset="https://blogit.create.pt/wp-content/uploads/2016/11/4-300x212.png 300w, https://blogit.create.pt/wp-content/uploads/2016/11/4-100x70.png 100w, https://blogit.create.pt/wp-content/uploads/2016/11/4.png 567w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>That&#8217;s it. I hope you enjoy it and have learn something.</p>
<p>The post <a href="https://blogit.create.pt/joaopais/2016/11/29/how-to-log-knockout-js-errors/">How to log knockout.js errors</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/joaopais/2016/11/29/how-to-log-knockout-js-errors/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
