<?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>Sharepoint 2013 &#8211; Kodono</title>
	<atom:link href="https://blog.kodono.info/wordpress/tag/sharepoint-2013/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.kodono.info/wordpress</link>
	<description>Pour tous les technophiles</description>
	<lastBuildDate>Tue, 11 Jul 2017 14:12:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>Bypass a lookup field not displayed because of threshold on NewForm and EditForm [Sharepoint 2013]</title>
		<link>https://blog.kodono.info/wordpress/2016/08/25/bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/</link>
					<comments>https://blog.kodono.info/wordpress/2016/08/25/bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/#comments</comments>
		
		<dc:creator><![CDATA[Aymeric]]></dc:creator>
		<pubDate>Thu, 25 Aug 2016 16:15:48 +0000</pubDate>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Niveau intermédiaire]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[Sharepoint 2013]]></category>
		<guid isPermaLink="false">https://blog.kodono.info/wordpress/?p=1687</guid>

					<description><![CDATA[EDIT 22/Dec/2016: there is s a new version of this article at https://blog.kodono.info/wordpress/2016/12/22/2-bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/ Sharepoint is really annoying to limit the access to the list with more than 5,000 items&#8230; It causes many troubles, and one of them is when you use a lookup field into a form that is tied to a big list. Sharepoint [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>EDIT 22/Dec/2016</strong>: there is s a new version of this article at <a href="https://blog.kodono.info/wordpress/2016/12/22/2-bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/">https://blog.kodono.info/wordpress/2016/12/22/2-bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/</a></p>
<p>Sharepoint is really annoying to limit the access to the list with more than 5,000 items&#8230; It causes many troubles, and one of them is when you use a lookup field into a form that is tied to a big list. Sharepoint will not display the field/dropdown but will show the message:</p>
<blockquote><p>This is a lookup column that displays data from another list that currently exceeds the List View Threshold defined by the administrator</p></blockquote>
<p>There is a solution to bypass this problem and show our lookup dropdowns.</p>
<p>You need:</p>
<ul>
<li><a href="http://jquery.com/">jQuery</a></li>
<li><a href="http://aymkdn.github.io/SharepointPlus/">Sharepoint</a></li>
<li>And I use <a href="https://harvesthq.github.io/chosen/">Chosen</a> to have a better dropdown</li>
</ul>
<p>I&#8217;ll show how I did it for the <strong>EditForm</strong>.</p>
<p>First, <strong>copy/paste the below JavaScript code</strong> into a file that you&#8217;ll store somewhere on your Sharepoint:</p>
<pre class="brush:javascript">
// load jQuery, SharepointPlus and Chosen
var toLoad = '&lt;script src="/Toolbox/Documents/js/jQuery/jquery-1.12.3.min.js">&lt;/script>'
           + '&lt;script src="/Toolbox/Documents/js/SharepointPlus/3.13/sharepointplus-3.13.min.js">&lt;/script>'
           + '&lt;link href="/Toolbox/Documents/js/Chosen/1.5.0/chosen.min.css" rel="stylesheet" type="text/css">'
           + '&lt;script src="/Toolbox/Documents/js/Chosen/1.5.0/chosen.jquery.min.js">&lt;/script>'
document.write(toLoad);

(function() {
  var aDeferred=[];
  var modal;
  // list the fields we want to fix
  // /!\ Add here the Field ID of the fields that need to be fixed
  var lookupFieldsToFix = ["Voucher_x0020_Code", "User_x0020_Name"];
  // /!\ Specify the name of the related list, as well as the Column to retrieve
  var configurationsLookup = [{list:"Vouchers", field:"Title"}, {list:"Users", field:"Name"}];

  // this function is triggered once the form is loaded
  function allLoaded(ctx) {
    // delete all existing localStorage
    localStorage.removeItem('RequestsLookup')
    // check if our call to lists are done
    $.when.apply(this, aDeferred).done(function() {
      var save={}, count=0, i;
      for (i=arguments.length; i--;) {
        if (arguments[i]) {
          save[arguments[i].field] = arguments[i].choices; // save it as {fieldName:choices}
          count++;
        }
      }
      if (count > 0) {
        // we use localStorage
        localStorage.setItem('RequestsLookup', JSON.stringify(save));
        // now reload the page
        $SP().closeModalDialog();
        $('#aspnetForm').hide().after('&lt;h1>Reloading...&lt;/h1>');
        window.location.reload();
      } else {
        // we use Chosen
        for (i=lookupFieldsToFix.length; i--;) {
          var e=WPQ2FormCtx.ListSchema[lookupFieldsToFix[i]];
          $(document.getElementById(e.Name+"_"+e.Id+"_$"+e.FieldType+"Field")).chosen({search_contains:true});
        }
        // and on Exam Name
        $SP().formfields("Exam Name").elem().chosen({search_contains:true});
      }
    })
  }
  
  /**
   * Fix the broken lookup fields
   * @param  {String} field Name of the field to fix
   * @return {Deferred}
   */  
  function fixLookup(field) {
    var deferred = jQuery.Deferred();
    var saved, choices=[], config;

    // we check if there is a Throttled
    if (WPQ2FormCtx.ListSchema[field].Throttled) {
      WPQ2FormCtx.ListSchema[field].Throttled=false;
      // check if we have a localStorage, if yes it means we are after the reload
      saved = localStorage.getItem("RequestsLookup");
      if (saved !== null) {
        saved = JSON.parse(saved);
        // we use the stored data to create our dropdown
        WPQ2FormCtx.ListSchema[field].ChoiceCount=saved[field].length;
        WPQ2FormCtx.ListSchema[field].Choices=saved[field];
        deferred.resolve();
      } else {
        WPQ2FormCtx.ListSchema[field].ChoiceCount=0;
        WPQ2FormCtx.ListSchema[field].Choices=[];
        // then we show a Waiting message
        if (!modal) {
          modal=true;
          $SP().waitModalDialog("Loading some data...");
        }
        // and we get data from the list
        config = configurationsLookup[SPArrayIndexOf(lookupFieldsToFix, field)];
        if (config.list) {
          $SP().list(config.list).get({fields:config.field, paging:true}, function(data) {
            var res=[];
            for (var i=data.length; i--;) {
              res.push({LookupId:data[i].getAttribute("ID"), LookupValue:data[i].getAttribute(config.field)});
            }
            deferred.resolve({field:field, choices:res});
          });
        } else deferred.resolve([]);
      }

    } else deferred.resolve();
    return deferred;
  }

  // do some actions as soon as the fields are shown
  var changeForm = {
    Templates: {
      OnPreRender:function(ctx) {
        // we want to show Voucher Code and User Name even if there are more than 5000 items in those lists
        if (SPArrayIndexOf(lookupFieldsToFix, ctx.ListSchema.Field[0].Name) > -1) {
          aDeferred.push(fixLookup(ctx.ListSchema.Field[0].Name));
        }
      },
      OnPostRender:function(ctx) {
        // only trigger when everything is loaded
        if (ctx.ListSchema.Field[0].Name === "Attachments") {
          allLoaded(ctx)
        }
      }
    }
  }
  // don't do it when editing the page
  if (GetUrlKeyValue("PageView") !== "Shared") SPClientTemplates.TemplateManager.RegisterTemplateOverrides(changeForm);
})();
</pre>
<p>Please refer to the <strong>/!\</strong> symbol to configure two variables: only <code>lookupFieldsToFix</code> and <code>configurationsLookup</code> need to be set by you.<br />
Note that the above code is compatible for IE8+, and all modern browsers.</p>
<p>Now go to the <strong>EditForm.aspx</strong> of your list. Then <strong>edit the page</strong>:<br />
<img fetchpriority="high" decoding="async" src="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture1.png" alt="showing how to edit the EditForm thru Settings" width="1091" height="313" class="aligncenter size-full wp-image-1691" srcset="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture1.png 1091w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture1-300x86.png 300w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture1-768x220.png 768w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture1-1024x294.png 1024w" sizes="(max-width: 1091px) 100vw, 1091px" /></p>
<p>Next, <strong>edit the webpart settings</strong>:<br />
<img decoding="async" src="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture2.png" alt="show how to edit webpart settings" width="840" height="432" class="aligncenter size-full wp-image-1690" srcset="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture2.png 840w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture2-300x154.png 300w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture2-768x395.png 768w" sizes="(max-width: 840px) 100vw, 840px" /></p>
<p>Go to the <strong>Miscellaneous section</strong> and enter the path to your JavaScript file (created before) in the <strong>JS Link</strong> field – you can use <code>~site</code> in the path:<br />
<img decoding="async" src="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture3.png" alt="show where to input the path to the JS file" width="346" height="385" class="aligncenter size-full wp-image-1692" srcset="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture3.png 346w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture3-270x300.png 270w" sizes="(max-width: 346px) 100vw, 346px" /></p>
<p>Finally click ON, and then on <strong>Stop Editing</strong> in the ribbon.</p>
<p>You can now try to edit an item and the lookup fields should be fixed. Example:<br />
<img loading="lazy" decoding="async" src="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture4.png" alt="" width="869" height="217" class="aligncenter size-full wp-image-1694" srcset="https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture4.png 869w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture4-300x75.png 300w, https://blog.kodono.info/wordpress/wp-content/uploads/2016/08/capture4-768x192.png 768w" sizes="auto, (max-width: 869px) 100vw, 869px" /></p>
<p><strong>NOTE</strong></p>
<p>The <code>document.write()</code> is not really a good practice because it will delay the page load. It would be better to load asyn the JS using <a href="https://gist.github.com/Aymkdn/98acfbb46fbe7c1f00cdd3c753520ea8">this tiny function</a>. In that case you need to make sure to have only Vanilla JS in your <code>changeForm</code>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.kodono.info/wordpress/2016/08/25/bypass-a-lookup-field-not-displayed-because-of-threshold-on-newform-and-editform-sharepoint-2013/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Send an email to several recipients from a String in a workflow [Sharepoint 2013]</title>
		<link>https://blog.kodono.info/wordpress/2016/06/28/send-an-email-to-several-recipients-from-a-string-in-a-workflow-sharepoint-2013/</link>
					<comments>https://blog.kodono.info/wordpress/2016/06/28/send-an-email-to-several-recipients-from-a-string-in-a-workflow-sharepoint-2013/#respond</comments>
		
		<dc:creator><![CDATA[Aymeric]]></dc:creator>
		<pubDate>Tue, 28 Jun 2016 07:22:44 +0000</pubDate>
				<category><![CDATA[Astuce]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Niveau intermédiaire]]></category>
		<category><![CDATA[Anglais]]></category>
		<category><![CDATA[Sharepoint 2013]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">https://blog.kodono.info/wordpress/?p=1665</guid>

					<description><![CDATA[I found the case in which I have to send 1 email to several recipients. I have the names stored into a Sharepoint list. Using REST API and a call into my Workflow I&#8217;ve been able to get a list of login names (using $expand=MyUserField and $select=MyUserField/Name), then you just need to concatenate them separate [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I found the case in which I have to send 1 email to several recipients. I have the names stored into a Sharepoint list.</p>
<p>Using REST API and a call into my Workflow I&#8217;ve been able to get a list of login names (using <code>$expand=MyUserField</code> and <code>$select=MyUserField/Name</code>), then you just need to concatenate them separate by <code>;</code>.</p>
<p>At the end you should have a string that looks like <code>domain\login_name1;domain\login_name2;domain\login_name3;</code> into yout <em>To</em> field for the email.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.kodono.info/wordpress/2016/06/28/send-an-email-to-several-recipients-from-a-string-in-a-workflow-sharepoint-2013/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Load a script once a DispForm is fully shown in Sharepoint 2013</title>
		<link>https://blog.kodono.info/wordpress/2016/05/30/load-a-script-once-a-dispform-is-fully-shown-in-sharepoint-2013/</link>
					<comments>https://blog.kodono.info/wordpress/2016/05/30/load-a-script-once-a-dispform-is-fully-shown-in-sharepoint-2013/#respond</comments>
		
		<dc:creator><![CDATA[Aymeric]]></dc:creator>
		<pubDate>Mon, 30 May 2016 10:48:54 +0000</pubDate>
				<category><![CDATA[Niveau intermédiaire]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[Sharepoint 2013]]></category>
		<guid isPermaLink="false">https://blog.kodono.info/wordpress/?p=1654</guid>

					<description><![CDATA[Sharepoint 2013 introduced the JSLink. This is very useful to play with forms and views. My attempt here is to remove some rows from the DispForm. To do so I needed to trigger an action as soon as the fields rendering has been done. After different tries, I finally came up with the PostRender option. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Sharepoint 2013 introduced the <a href="http://jsuhail.blogspot.fr/2014/09/client-side-rendering-using-jslink-post_30.html">JSLink</a>. This is very useful to play with forms and views.</p>
<p>My attempt here is to remove some rows from the DispForm. To do so I needed to trigger an action as soon as the fields rendering has been done. After different tries, I finally came up with the <code>PostRender</code> option.</p>
<pre class="brush:javascript">
// https://gist.github.com/Aymkdn/98acfbb46fbe7c1f00cdd3c753520ea8
function loadExt(e,t){var s=this;s.files=e,s.js=[],s.head=document.getElementsByTagName("head")[0],s.after=t||function(){},s.loadStyle=function(e){var t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.href=e,s.head.appendChild(t)},s.loadScript=function(e){var t=document.createElement("script");t.type="text/javascript",t.src=s.js[e];var a=function(){++e&lt;s.js.length?s.loadScript(e):s.after()};t.onload=function(){a()},s.head.appendChild(t)};for(var a=0;a&lt;s.files.length;a++)/\.js$|\.js\?/.test(s.files[a])&#038;&s.js.push(s.files[a]),/\.css$|\.css\?/.test(s.files[a])&#038;&s.loadStyle(s.files[a]);s.js.length>0?s.loadScript(0):s.after()}

// verify when all scripts have been loaded
var loadExtLoaded = false;
function checkExt(ctx) {
  if (loadExtLoaded) {
    // here you can call a function that is in one of the called script
  } else {
    setTimeout(function() { checkExt(ctx) }, 50);
  }
}
loadExt([
  'file_you_want_to_load.js',
  'style_you_want_to_load.css',
  'no_cache_file.js?timestamp='+(Date.now())
], function() {
  loadExtLoaded=true;
});

(function() {
  function onLoad(ctx) {
    checkExt(ctx);
  }

  // do some actions as soon as the fields are shown
  var loadAfterForm = {
    Templates: {
      OnPostRender:function(ctx) {
         // only trigger when everything is loaded
        // --> ctx.ListData.Items[0] all the fields
        if (ctx.ListSchema.Field[0].Name === "Attachments") {
          onLoad(ctx)
        }
      }
    }
  }
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(loadAfterForm);
})();
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.kodono.info/wordpress/2016/05/30/load-a-script-once-a-dispform-is-fully-shown-in-sharepoint-2013/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to expand Sharepoint 2013 calendar by default [JavaScript]</title>
		<link>https://blog.kodono.info/wordpress/2015/11/02/how-to-expand-sharepoint-2013-calendar-by-default-javascript/</link>
					<comments>https://blog.kodono.info/wordpress/2015/11/02/how-to-expand-sharepoint-2013-calendar-by-default-javascript/#comments</comments>
		
		<dc:creator><![CDATA[Aymeric]]></dc:creator>
		<pubDate>Mon, 02 Nov 2015 15:16:32 +0000</pubDate>
				<category><![CDATA[Niveau intermédiaire]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[Sharepoint 2013]]></category>
		<guid isPermaLink="false">http://blog.kodono.info/wordpress/?p=1562</guid>

					<description><![CDATA[This code has been tested for Sharepoint 2013 only. It permits to expand by default (so as soon as the page is loaded) the events in the Month calendar view. See here a solution for Sharepoint 2010. Tested with IE8 and Firefox 41. You&#8217;ll have to add the below JavaScript code into your calendar page: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This code has been tested for Sharepoint 2013 only. It permits to expand by default (so as soon as the page is loaded) the events in the Month calendar view.</p>
<p><a href="http://blog.kodono.info/wordpress/2014/12/18/how-to-expand-sharepoint-2010-calendar-by-default-javascript/">See here a solution for Sharepoint 2010</a>.</p>
<p>Tested with IE8 and Firefox 41. You&#8217;ll have to add the below JavaScript code into your calendar page:</p>
<pre class="brush:javascript">
// the below function simulate a click on a link
function fireEventClick(elem){
    if(document.createEvent){                                                 
      var e = document.createEvent('MouseEvents');
      e.initMouseEvent('click', /* Event type */
      true, /* Can bubble */
      true, /* Cancelable */
      document.defaultView, /* View */
      1, /* Mouse clicks */
      0, /* Screen x */
      0, /* Screen y */
      0, /* Client x */
      0, /* Client y */
      false, /* Ctrl */
      false, /* Alt */
      false, /* Shift */
      false, /* Meta */
      0, /* Button */
      null); /* Related target */
      elem.dispatchEvent(e);                     
    } else { // pour IE
      elem.click();
    }
}

// Expand the events
// because Sharepoint redraw ALL the events when we click on Expand, then we need a special recurrent function
function ExpandEvents(idx) {
  var a = document.querySelectorAll('a[evtid="expand_collapse"]');
  if (idx &lt; a.length) {
    if (a[idx].parentNode.getAttribute("_expand") !== "collapse") fireEventClick(a[idx]);
    ExpandEvents(++idx);
  }
}

function onCalendarGridsRendered(){
  setTimeout(function() {
    ExpandEvents(0)
  }, 250)
}

// some code reused from http://www.codeproject.com/Tips/759006/Enhancing-SharePoint-Calendar-sp-ui-applicationpag
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
    //Week or Day Calendar View
    SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids_Old = SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids;
    SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids = function SP_UI_ApplicationPages_DetailCalendarView$renderGrids($p0) {
      this.renderGrids_Old($p0);
      onCalendarGridsRendered();
    };
    
    //Month Calendar View
    SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids_Old = SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids;
    SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids = function SP_UI_ApplicationPages_SummaryCalendarView$renderGrids($p0) {
      this.renderGrids_Old($p0);
      onCalendarGridsRendered();
    };
    
    ExpandEvents(0)
}, "SP.UI.ApplicationPages.Calendar.js");
</pre>
<p>And we can hide the &#8220;Collapse&#8221; links with one line of CSS:</p>
<pre class="brush:css">
.ms-cal-nav[evtid="expand_collapse"] { display: none !important }
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.kodono.info/wordpress/2015/11/02/how-to-expand-sharepoint-2013-calendar-by-default-javascript/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
