CAMLQuery: "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where><OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query>",
Showing posts with label SPServices. Show all posts
Showing posts with label SPServices. Show all posts
Tuesday, 29 January 2019
SP Services: How to get SharePoint list items in ascending or descending order?
CAMLQuery: "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where><OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query>",
SP Services: How to populate a dropdown box with unique values from a SharePoint list column?
<script language="javascript" type="text/javascript">
$( document ).ready(function(){
loadFunction();
})
function loadFunction()
{
$().SPServices({
operation: "GetListItems",
async: false,
listName: "List Name",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLQuery: "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where><OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var opTitle = $(this).attr("ows_Title");
var opOption = "<option value="+opTitle+">" + opTitle + "</option>"
$("select.opselector").append(opOption);
});
}
});
//Remove duplicate values
$(".opselector option").val(function(idx, val) {
$(this).siblings('[value="'+ val +'"]').remove();
});
}
//Get selected text
function getOP()
{
alert($(".opselector option:selected").html());
}
<body>
<select class="opselector" onchange="getOP();"></select>
</body>
Labels:
csom,
distinct,
javascript,
jQuery,
sharepoint,
SPServices
Tuesday, 17 April 2018
[Solved] SPServices : GetListItems not returning all items from SharePoint list?
'GetListItems' will return items from default list view only.
To overcome this use the following filters:
var cmlQuery="<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where></Query>";
CAMLQuery: cmlQuery, //Include items which are filtered-out in default view
CAMLRowLimit: 0, //Override default view row-limit
Labels:
caml,
list,
list items,
ListViews,
sharepoint,
SPServices
Tuesday, 3 April 2018
SPServices : How to prepare date data for the SharePoint list date field using JavaScript?
var currDate = new Date();
var numDay=currDate.getDate();
var numMonth = currDate.getMonth();
var numYear = currDate.getFullYear();
var tempDate = (++numMonth)+"/"+(numDay)+"/"+numYear ;
var spDate = new Date(tempDate).toISOString();
//e.g. 2019-08-29T18:30:00.000Z
Note: You may have to adjust numDay based on the timezone.
Labels:
date,
format,
javascript,
SPServices
How to fetch the email of the current user using SPServices?
$( document ).ready(function(){
currUser = $().SPServices.SPGetCurrentUser({
fieldNames: ["WorkEmail"],
debug: false
});
currUserEmail = currUser.split('p|')[1];
})
Labels:
javascript,
jQuery,
profile,
sharepoint,
sharepoint designer,
SPServices,
user
Saturday, 31 March 2018
How to get and update SharePoint list using SPServices and w2ui grid table?
Sample Page (SharePoint Designer):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/jquery.SPServices.min.js"></script>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/w2ui-1.5.rc1.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://domain.com/sites/siteName/SiteAssets/scripts/w2ui-1.5.rc1.min.css" />
<script language="javascript" type="text/javascript">
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var cmlQuery="<Query><Where><Eq><FieldRef Name='Column Name'/><Value Type='Text'><![CDATA[" + decodeURI(getParameterByName('queryStringParameter',window.location.href))+ "]]></Value></Eq></Where></Query>";
var listData=[];
var counter=0;
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "List Name",
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: cmlQuery,
CAMLRowLimit: 0,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
listData.push({recid: $(this).attr("ows_ID"),Boolean: ($(this).attr("ows_Check_x0020_Box")=="1"),Resource: $(this).attr("ows_Enterprise_x0020_ID").split('#')[1]});
});
}
});
});
function UpdateItem(_id,_boolean)
{
$().SPServices({
operation: "UpdateListItems",
listName: "List Name",
ID: _id,
valuepairs: [["Check_x0020_Box", _boolean]],
completefunc: function (xData, Status) {
//alert(Status);
}
});
}
$(function () {
$('#grid').w2grid({
name: 'grid',
show: {
toolbar: true,
footer: true,
toolbarSave: true
},
columns: [
// { field: 'recid', caption: 'ID', size: '50px', sortable: true, resizable: true,show:false },
{ field: 'Boolean', caption: 'Boolean', size: '60px', sortable: true, resizable: true, style: 'text-align: center',
editable: { type: 'checkbox', style: 'text-align: center' }
},
{ field: 'Resource', caption: 'Resource', size: '120px', sortable: true, resizable: true}
],
onSave: function (event) {
var changeArr=w2ui['grid'].getChanges();
$(changeArr).each(function() {
UpdateItem($(this).attr("recid"),$(this).attr("Boolean"));
});
w2alert('Saved!');
},
records:listData
});
if(w2ui['grid'].records.length==0)
{
$("#grid").hide();
w2alert('No pending items. Thanks!');
}
});
</script>
</head>
<body>
<div id="grid" style="width: 100%; height: 400px;"></div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/jquery.SPServices.min.js"></script>
<script type="text/javascript" src="https://domain.com/sites/siteName/SiteAssets/scripts/w2ui-1.5.rc1.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://domain.com/sites/siteName/SiteAssets/scripts/w2ui-1.5.rc1.min.css" />
<script language="javascript" type="text/javascript">
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var cmlQuery="<Query><Where><Eq><FieldRef Name='Column Name'/><Value Type='Text'><![CDATA[" + decodeURI(getParameterByName('queryStringParameter',window.location.href))+ "]]></Value></Eq></Where></Query>";
var listData=[];
var counter=0;
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "List Name",
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: cmlQuery,
CAMLRowLimit: 0,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
listData.push({recid: $(this).attr("ows_ID"),Boolean: ($(this).attr("ows_Check_x0020_Box")=="1"),Resource: $(this).attr("ows_Enterprise_x0020_ID").split('#')[1]});
});
}
});
});
function UpdateItem(_id,_boolean)
{
$().SPServices({
operation: "UpdateListItems",
listName: "List Name",
ID: _id,
valuepairs: [["Check_x0020_Box", _boolean]],
completefunc: function (xData, Status) {
//alert(Status);
}
});
}
$(function () {
$('#grid').w2grid({
name: 'grid',
show: {
toolbar: true,
footer: true,
toolbarSave: true
},
columns: [
// { field: 'recid', caption: 'ID', size: '50px', sortable: true, resizable: true,show:false },
{ field: 'Boolean', caption: 'Boolean', size: '60px', sortable: true, resizable: true, style: 'text-align: center',
editable: { type: 'checkbox', style: 'text-align: center' }
},
{ field: 'Resource', caption: 'Resource', size: '120px', sortable: true, resizable: true}
],
onSave: function (event) {
var changeArr=w2ui['grid'].getChanges();
$(changeArr).each(function() {
UpdateItem($(this).attr("recid"),$(this).attr("Boolean"));
});
w2alert('Saved!');
},
records:listData
});
if(w2ui['grid'].records.length==0)
{
$("#grid").hide();
w2alert('No pending items. Thanks!');
}
</script>
</head>
<body>
<div id="grid" style="width: 100%; height: 400px;"></div>
</body>
</html>
Labels:
caml,
grid,
sharepoint,
SPServices,
table,
w2ui
Friday, 29 September 2017
SPServices : How to update SharePoint list item?
$(document).ready(updateListItem(12,"Next3"));
function updateListItem(itmeID,newTitle) {
$().SPServices({
//webURL: "https://domain/site_coll/site/",
operation: "UpdateListItems",
valuepairs: [["Title", newTitle]],
async: false,
listName: "Test List",
ID: itmeID,
completefunc: success_updateListItem
});
}
function success_updateListItem(xData, status) {
alert(status);
}
Thursday, 28 September 2017
SPServices: How to fetch filtered SharePoint list items?
$(document).ready(getListItems);
function getListItems() {
$().SPServices({
//webURL: "https://domain/sites/site_collection/site",
operation: "GetListItems",
async: false,
listName: "Test List",
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>YourValueHere</Value></Eq></Where></Query>",
completefunc: success_getListItems
});
}
function success_getListItems(xData, status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
SPServices: How to fetch SharePoint list items with all fields?
$(document).ready(getListItems);
function getListItems() {
$().SPServices({
//webURL: "https://domain/sites/site_collection/site",
operation: "GetListItems",
async: false,
listName: "Test List",
CAMLViewFields: "<ViewFields Properties='True' />",
completefunc: success_getListItems
});
}
function success_getListItems(xData, status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
Subscribe to:
Posts (Atom)