Étiquette : Programmation

Problem with the People Picker of Sharepoint

For one of my list I’ve had a very weird issue: one people picker didn’t work properly. If I entered a name and clicked to check it, then it didn’t work. If I saved it and then got back to the form, the value didn’t appear. This strange behavior is due to a missing SPAN […]

Communication between iframe and parent window [JavaScript]

In the iframe you’ll use the below code: window.parent.postMessage(« Hello World ! », « http://your.site.web »); And in the parent window: // function that will be called when the message is received function receiveMessage(event) { alert(event.data); // it’ll show « Hello World ! » } // we listen to a message if (window.addEventListener) { window.addEventListener(‘message’, receiveMessage, false); } else if (window.attachEvent) […]

How to edit the default action for an icon in a Sharepoint Ribbon

I wanted to change the behavior of the « Edit Item » button from the Sharepoint 2010 ribbon of the Display Form (DispForm.aspx). It wasn’t really easy, so I finally found a solution that I’m going to share here. You’ll need to use JavaScript for that. In the below example, the click on the « Edit Item » will […]

Show/Hide a Sharepoint fields in the NewForm, EditForm and DispForm

With the Sharepoint WebServices it’s possible to hide a field into the NewForm, the Editform and/or the DispForm. You’ll need to use JavaScript with jQuery and SPServices. It’s the UpdateList service that will do the trick. Once you have loaded the both librairies you can use the below code: var fieldsToUpdate = ‘<Fields>’; fieldsToUpdate += […]

Delete a User Custom Action from Sharepoint [JavaScript]

The MSDN documentation is a nightmare…. For example Microsoft provides an example to create a User Custom Action for Sharepoint, however there is no code about how to delete it. So here is the code to use to delete the usercustomaction just created with the above example: var siteUrl = ‘/site collection/site/’; function deleteUserCustomAction() { […]

Dynamically inject a CSS code into the page [JavaScript]

Mozilla created a function that permits to inject some CSS into the document: addStylesheetRules() But if you use jQuery you may want to use this function: function injectCSS(rule) { $(« head »).append(‘<style>’ + rule + ‘</style>’) } // example injectCSS(« div { padding:5px } »)

Tiny AJAX

This is a very tiny javascript code to do an AJAX Request: /* m: method (« get », « post ») u: url a: async (true) or sync (false) c: callback (with ‘xhr’ as a parameter) d: post_data (the data to post) */ function tiny_ajax(m,u,a,c,d){with(new(this.XMLHttpRequest||ActiveXObject)(« Microsoft.XMLHTTP »))onreadystatechange=function(){readyState^4||c(this)},open(m,u,a),send(d)} And an example: tiny_ajax(‘get’, ‘http://www.google.com’, true, function(xhr) { alert(xhr.responseText) })

Show the full content of a Sharepoint Calendar event box

With a Sharepoint Calendar the events with a long title/description are cropped and you cannot see the full description, except if you move your mouse over it. Example: So I’ve had to do some CSS and a complicated JavaScript code to be able to create some large boxes. Now we are able to see the […]

Override SharePoint OOTB Upload.aspx default for « Add as a new version to existing files » checkbox

With Sharepoint, when we want to upload a file, the « Add as a new version to existing file » is checked by default, and that could be an issue for you. Here is a JavaScript fix to add into your masterpage, just before the </head> tag : <script type= »text/javascript »> function DefaultUploadOverwriteOff() { if (document.title.indexOf(« Upload Document ») > […]

Requête MySQL insensible aux accents

Pour effectuer une requête MySQL qui ne sera pas sensible aux accents (par exemple ‘ö’ = ‘o’ ou ‘à’ = ‘a’) il faut rajouter le mot clé COLLATE avec la bonne collection. Après plusieurs tests, j’utilise la collection utf8_general_ci. Ce qui donnera : SELECT ID, Nom FROM Inscrits WHERE Nom LIKE ‘%heracles%’ COLLATE utf8_general_ci ORDER […]