Skip to content

Instantly share code, notes, and snippets.

View javierguerrero's full-sized avatar
🏠
Working from home

Javier Guerrero javierguerrero

🏠
Working from home
View GitHub Profile
@javierguerrero
javierguerrero / gist:3083683
Created July 10, 2012 14:37
Split Function in Sql Server to break Comma-Separated Strings into Table
CREATE FUNCTION dbo.Split(@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (items varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
@javierguerrero
javierguerrero / CSOMJavaScriptInsert.js
Last active August 29, 2015 14:07
CSOMJavaScriptInsert.js
//<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
@javierguerrero
javierguerrero / CSOMJavaScriptRead.js
Last active August 29, 2015 14:07
CSOMJavaScriptRead.js
//<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
jQuery(document).ready(function($) {
ExecuteOrDelayUntilScriptLoaded(function () {sharePointReady();}, "sp.js");
});
function sharePointReady(){
var website = "http://sp.local";
var list = "Mis Contactos";
var pais = "Peru";
getItemsByPais(website, list, pais);
@javierguerrero
javierguerrero / CSOMJavaScriptUpdate.js
Last active August 29, 2015 14:07
CSOMJavaScriptUpdate.js
function updateListItem(listName, id,title) {
var ctx = new SP.ClientContext();
var oList = ctx.get_web().get_lists().getByTitle(listName);
var olistItem = oList.getItemById(id);
olistItem.set_item("Title", title);
olistItem.update();
ctx.load(olistItem);
ctx.executeQueryAsync(
function () {
console.log('updated success');
@javierguerrero
javierguerrero / CSOMJavaScriptDelete.js
Last active August 29, 2015 14:07
CSOMJavaScriptDelete.js
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(function(){sharePointReady();}, "sp.js");
});
function sharePointReady(){
var list = "MisContactos";
var id = 4;
$("#delete").click(function(){
@javierguerrero
javierguerrero / GetWebIDWithJavaScript.js
Created October 4, 2014 22:06
GetWebIDWithJavaScript.js
<script>
ExecuteOrDelayUntilScriptLoaded(PageLoad, "sp.js");
function PageLoad() {
debugger;
this.ctx = SP.ClientContext.get_current();
this.web = ctx.get_web();
this.ctx.load(this.web);
ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
@javierguerrero
javierguerrero / SPSOAPSPServicesRead.js
Created October 4, 2014 22:55
SPSOAPSPServicesRead.js
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "MisContactos",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
@javierguerrero
javierguerrero / ExtractWSPSolution.ps1
Last active August 29, 2015 14:07
ExtractWSPSolution.ps1
$farm = Get-SPFarm
$file = $farm.Solutions.Item("extendeddiagnosticproviders.wsp").SolutionFile
$file.SaveAs("c:\temp\extendeddiagnosticproviders.wsp")
@javierguerrero
javierguerrero / HabilitarDeveloperDashboard.ps1
Created October 5, 2014 12:42
Habilitar el Developer Dashboard
#Habilitar
$svc=[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$ddsetting=$svc.DeveloperDashboardSettings
$ddsetting.DisplayLevel=[Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
$ddsetting.Update()
#Deshabilitar
$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
/**
* Created by jagp on 11/10/2014.
*/
var TrafficLight = function () {
var count = 0;
var currentState = new Red(this);
this.change = function (state) {
// limits number of changes
if (count++ >= 10) return;