/*
* SPServices - Work with SharePoint's Web Services using jQuery
* Version 2014.02
* @requires jQuery v1.8 or greater - jQuery 1.10.x+ recommended
*
* Copyright (c) 2009-2014 Sympraxis Consulting LLC
* Examples and docs at:
* http://spservices.codeplex.com
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/
/*
* @description Work with SharePoint's Web Services using jQuery
* @type jQuery
* @name SPServices
* @category Plugins/SPServices
* @author Sympraxis Consulting LLC/marc.anderson@sympraxisconsulting.com
*/
/* jshint undef: true */
/* global L_Menu_BaseUrl, _spUserId, _spPageContextInfo, GipAddSelectedItems, GipRemoveSelectedItems, GipGetGroupData */
(function ($) {
"use strict";
// Version info
var VERSION = "2014.02"; // TODO: Update version
// String constants
// General
var SLASH = "/";
var spDelim = ";#";
var TXTColumnNotFound = "Column not found on page";
var SCHEMASharePoint = "http://schemas.microsoft.com/sharepoint";
var multiLookupPrefix = "MultiLookupPicker";
var multiLookupPrefix2013 = "MultiLookup";
// Dropdown Types
var dropdownType = {
simple: "S",
complex: "C",
multiSelect: "M"
};
// Known list field types - See: http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spfieldtype(v=office.15).aspx
var spListFieldTypes = [
"Integer",
"Text",
"Note",
"DateTime",
"Counter",
"Choice",
"Lookup",
"Boolean",
"Number",
"Currency",
"URL",
// "Computed", // NEW
// "Threading", // NEW
// "Guid", // NEW
"MultiChoice",
// "GridChoice", // NEW
"Calculated",
"File",
"Attachments",
"User",
// "Recurrence", // NEW
// "CrossProjectLink", // NEW
"ModStat",
"ContentTypeId",
// "PageSeparator", // NEW
// "ThreadIndex", // NEW
"WorkflowStatus", // NEW
// "AllDayEvent", // NEW
// "WorkflowEventType", // NEW
// "Geolocation", // NEW
// "OutcomeChoice", // NEW
// Also seen
"UserMulti", // Multiselect users
"LookupMulti", // Multi-select lookup
"datetime", // Calculated date/time result
"float", // Calculated float
"Calc" // General calculated
];
// Caching
var promisesCache = {};
// Web Service names
var ALERTS = "Alerts";
var AUTHENTICATION = "Authentication";
var COPY = "Copy";
var FORMS = "Forms";
var LISTS = "Lists";
var MEETINGS = "Meetings";
var OFFICIALFILE = "OfficialFile";
var PEOPLE = "People";
var PERMISSIONS = "Permissions";
var PUBLISHEDLINKSSERVICE = "PublishedLinksService";
var SEARCH = "Search";
var SHAREPOINTDIAGNOSTICS = "SharePointDiagnostics";
var SITEDATA = "SiteData";
var SITES = "Sites";
var SOCIALDATASERVICE = "SocialDataService";
var SPELLCHECK = "SpellCheck";
var TAXONOMYSERVICE = "TaxonomyClientService";
var USERGROUP = "usergroup";
var USERPROFILESERVICE = "UserProfileService";
var VERSIONS = "Versions";
var VIEWS = "Views";
var WEBPARTPAGES = "WebPartPages";
var WEBS = "Webs";
var WORKFLOW = "Workflow";
// Global variables
var currentContext = new SPServicesContext(); // Variable to hold the current context as we figure it out
var i = 0; // Generic loop counter
var encodeOptionList = ["listName", "description"]; // Used to encode options which may contain special characters
// Array to store Web Service information
// WSops.OpName = [WebService, needs_SOAPAction];
// OpName The name of the Web Service operation -> These names are unique
// WebService The name of the WebService this operation belongs to
// needs_SOAPAction Boolean indicating whether the operatio needs to have the SOAPAction passed in the setRequestHeaderfunction.
// true if the operation does a write, else false
var WSops = [];
WSops.GetAlerts = [ALERTS, false];
WSops.DeleteAlerts = [ALERTS, true];
WSops.Mode = [AUTHENTICATION, false];
WSops.Login = [AUTHENTICATION, false];
WSops.CopyIntoItems = [COPY, true];
WSops.CopyIntoItemsLocal = [COPY, true];
WSops.GetItem = [COPY, false];
WSops.GetForm = [FORMS, false];
WSops.GetFormCollection = [FORMS, false];
WSops.AddAttachment = [LISTS, true];
WSops.AddDiscussionBoardItem = [LISTS, true];
WSops.AddList = [LISTS, true];
WSops.AddListFromFeature = [LISTS, true];
WSops.ApplyContentTypeToList = [LISTS, true];
WSops.CheckInFile = [LISTS, true];
WSops.CheckOutFile = [LISTS, true];
WSops.CreateContentType = [LISTS, true];
WSops.DeleteAttachment = [LISTS, true];
WSops.DeleteContentType = [LISTS, true];
WSops.DeleteContentTypeXmlDocument = [LISTS, true];
WSops.DeleteList = [LISTS, true];
WSops.GetAttachmentCollection = [LISTS, false];
WSops.GetList = [LISTS, false];
WSops.GetListAndView = [LISTS, false];
WSops.GetListCollection = [LISTS, false];
WSops.GetListContentType = [LISTS, false];
WSops.GetListContentTypes = [LISTS, false];
WSops.GetListItemChanges = [LISTS, false];
WSops.GetListItemChangesSinceToken = [LISTS, false];
WSops.GetListItems = [LISTS, false];
WSops.GetVersionCollection = [LISTS, false];
WSops.UndoCheckOut = [LISTS, true];
WSops.UpdateContentType = [LISTS, true];
WSops.UpdateContentTypesXmlDocument = [LISTS, true];
WSops.UpdateContentTypeXmlDocument = [LISTS, true];
WSops.UpdateList = [LISTS, true];
WSops.UpdateListItems = [LISTS, true];
WSops.AddMeeting = [MEETINGS, true];
WSops.CreateWorkspace = [MEETINGS, true];
WSops.RemoveMeeting = [MEETINGS, true];
WSops.SetWorkSpaceTitle = [MEETINGS, true];
WSops.GetRecordRouting = [OFFICIALFILE, false];
WSops.GetRecordRoutingCollection = [OFFICIALFILE, false];
WSops.GetServerInfo = [OFFICIALFILE, false];
WSops.SubmitFile = [OFFICIALFILE, true];
WSops.ResolvePrincipals = [PEOPLE, true];
WSops.SearchPrincipals = [PEOPLE, false];
WSops.AddPermission = [PERMISSIONS, true];
WSops.AddPermissionCollection = [PERMISSIONS, true];
WSops.GetPermissionCollection = [PERMISSIONS, true];
WSops.RemovePermission = [PERMISSIONS, true];
WSops.RemovePermissionCollection = [PERMISSIONS, true];
WSops.UpdatePermission = [PERMISSIONS, true];
WSops.GetLinks = [PUBLISHEDLINKSSERVICE, true];
WSops.GetPortalSearchInfo = [SEARCH, false];
WSops.GetQuerySuggestions = [SEARCH, false];
WSops.GetSearchMetadata = [SEARCH, false];
WSops.Query = [SEARCH, false];
WSops.QueryEx = [SEARCH, false];
WSops.Registration = [SEARCH, false];
WSops.Status = [SEARCH, false];
WSops.SendClientScriptErrorReport = [SHAREPOINTDIAGNOSTICS, true];
WSops.GetAttachments = [SITEDATA, false];
WSops.EnumerateFolder = [SITEDATA, false];
WSops.SiteDataGetList = [SITEDATA, false];
WSops.SiteDataGetListCollection = [SITEDATA, false];
WSops.SiteDataGetSite = [SITEDATA, false];
WSops.SiteDataGetSiteUrl = [SITEDATA, false];
WSops.SiteDataGetWeb = [SITEDATA, false];
WSops.CreateWeb = [SITES, true];
WSops.DeleteWeb = [SITES, true];
WSops.GetSite = [SITES, false];
WSops.GetSiteTemplates = [SITES, false];
WSops.AddComment = [SOCIALDATASERVICE, true];
WSops.AddTag = [SOCIALDATASERVICE, true];
WSops.AddTagByKeyword = [SOCIALDATASERVICE, true];
WSops.CountCommentsOfUser = [SOCIALDATASERVICE, false];
WSops.CountCommentsOfUserOnUrl = [SOCIALDATASERVICE, false];
WSops.CountCommentsOnUrl = [SOCIALDATASERVICE, false];
WSops.CountRatingsOnUrl = [SOCIALDATASERVICE, false];
WSops.CountTagsOfUser = [SOCIALDATASERVICE, false];
WSops.DeleteComment = [SOCIALDATASERVICE, true];
WSops.DeleteRating = [SOCIALDATASERVICE, true];
WSops.DeleteTag = [SOCIALDATASERVICE, true];
WSops.DeleteTagByKeyword = [SOCIALDATASERVICE, true];
WSops.DeleteTags = [SOCIALDATASERVICE, true];
WSops.GetAllTagTerms = [SOCIALDATASERVICE, false];
WSops.GetAllTagTermsForUrlFolder = [SOCIALDATASERVICE, false];
WSops.GetAllTagUrls = [SOCIALDATASERVICE, false];
WSops.GetAllTagUrlsByKeyword = [SOCIALDATASERVICE, false];
WSops.GetCommentsOfUser = [SOCIALDATASERVICE, false];
WSops.GetCommentsOfUserOnUrl = [SOCIALDATASERVICE, false];
WSops.GetCommentsOnUrl = [SOCIALDATASERVICE, false];
WSops.GetRatingAverageOnUrl = [SOCIALDATASERVICE, false];
WSops.GetRatingOfUserOnUrl = [SOCIALDATASERVICE, false];
WSops.GetRatingOnUrl = [SOCIALDATASERVICE, false];
WSops.GetRatingsOfUser = [SOCIALDATASERVICE, false];
WSops.GetRatingsOnUrl = [SOCIALDATASERVICE, false];
WSops.GetSocialDataForFullReplication = [SOCIALDATASERVICE, false];
WSops.GetTags = [SOCIALDATASERVICE, true];
WSops.GetTagsOfUser = [SOCIALDATASERVICE, true];
WSops.GetTagTerms = [SOCIALDATASERVICE, true];
WSops.GetTagTermsOfUser = [SOCIALDATASERVICE, true];
WSops.GetTagTermsOnUrl = [SOCIALDATASERVICE, true];
WSops.GetTagUrlsOfUser = [SOCIALDATASERVICE, true];
WSops.GetTagUrlsOfUserByKeyword = [SOCIALDATASERVICE, true];
WSops.GetTagUrls = [SOCIALDATASERVICE, true];
WSops.GetTagUrlsByKeyword = [SOCIALDATASERVICE, true];
WSops.SetRating = [SOCIALDATASERVICE, true];
WSops.UpdateComment = [SOCIALDATASERVICE, true];
WSops.SpellCheck = [SPELLCHECK, false];
// Taxonomy Service Calls
// Updated 2011.01.27 by Thomas McMillan
WSops.AddTerms = [TAXONOMYSERVICE, true];
WSops.GetChildTermsInTerm = [TAXONOMYSERVICE, false];
WSops.GetChildTermsInTermSet = [TAXONOMYSERVICE, false];
WSops.GetKeywordTermsByGuids = [TAXONOMYSERVICE, false];
WSops.GetTermsByLabel = [TAXONOMYSERVICE, false];
WSops.GetTermSets = [TAXONOMYSERVICE, false];
WSops.AddGroup = [USERGROUP, true];
WSops.AddGroupToRole = [USERGROUP, true];
WSops.AddRole = [USERGROUP, true];
WSops.AddRoleDef = [USERGROUP, true];
WSops.AddUserCollectionToGroup = [USERGROUP, true];
WSops.AddUserCollectionToRole = [USERGROUP, true];
WSops.AddUserToGroup = [USERGROUP, true];
WSops.AddUserToRole = [USERGROUP, true];
WSops.GetAllUserCollectionFromWeb = [USERGROUP, false];
WSops.GetGroupCollection = [USERGROUP, false];
WSops.GetGroupCollectionFromRole = [USERGROUP, false];
WSops.GetGroupCollectionFromSite = [USERGROUP, false];
WSops.GetGroupCollectionFromUser = [USERGROUP, false];
WSops.GetGroupCollectionFromWeb = [USERGROUP, false];
WSops.GetGroupInfo = [USERGROUP, false];
WSops.GetRoleCollection = [USERGROUP, false];
WSops.GetRoleCollectionFromGroup = [USERGROUP, false];
WSops.GetRoleCollectionFromUser = [USERGROUP, false];
WSops.GetRoleCollectionFromWeb = [USERGROUP, false];
WSops.GetRoleInfo = [USERGROUP, false];
WSops.GetRolesAndPermissionsForCurrentUser = [USERGROUP, false];
WSops.GetRolesAndPermissionsForSite = [USERGROUP, false];
WSops.GetUserCollection = [USERGROUP, false];
WSops.GetUserCollectionFromGroup = [USERGROUP, false];
WSops.GetUserCollectionFromRole = [USERGROUP, false];
WSops.GetUserCollectionFromSite = [USERGROUP, false];
WSops.GetUserCollectionFromWeb = [USERGROUP, false];
WSops.GetUserInfo = [USERGROUP, false];
WSops.GetUserLoginFromEmail = [USERGROUP, false];
WSops.RemoveGroup = [USERGROUP, true];
WSops.RemoveGroupFromRole = [USERGROUP, true];
WSops.RemoveRole = [USERGROUP, true];
WSops.RemoveUserCollectionFromGroup = [USERGROUP, true];
WSops.RemoveUserCollectionFromRole = [USERGROUP, true];
WSops.RemoveUserCollectionFromSite = [USERGROUP, true];
WSops.RemoveUserFromGroup = [USERGROUP, true];
WSops.RemoveUserFromRole = [USERGROUP, true];
WSops.RemoveUserFromSite = [USERGROUP, true];
WSops.RemoveUserFromWeb = [USERGROUP, true];
WSops.UpdateGroupInfo = [USERGROUP, true];
WSops.UpdateRoleDefInfo = [USERGROUP, true];
WSops.UpdateRoleInfo = [USERGROUP, true];
WSops.UpdateUserInfo = [USERGROUP, true];
WSops.AddColleague = [USERPROFILESERVICE, true];
WSops.AddLink = [USERPROFILESERVICE, true];
WSops.AddMembership = [USERPROFILESERVICE, true];
WSops.AddPinnedLink = [USERPROFILESERVICE, true];
WSops.CreateMemberGroup = [USERPROFILESERVICE, true];
WSops.CreateUserProfileByAccountName = [USERPROFILESERVICE, true];
WSops.GetCommonColleagues = [USERPROFILESERVICE, false];
WSops.GetCommonManager = [USERPROFILESERVICE, false];
WSops.GetCommonMemberships = [USERPROFILESERVICE, false];
WSops.GetInCommon = [USERPROFILESERVICE, false];
WSops.GetPropertyChoiceList = [USERPROFILESERVICE, false];
WSops.GetUserColleagues = [USERPROFILESERVICE, false];
WSops.GetUserLinks = [USERPROFILESERVICE, false];
WSops.GetUserMemberships = [USERPROFILESERVICE, false];
WSops.GetUserPinnedLinks = [USERPROFILESERVICE, false];
WSops.GetUserProfileByGuid = [USERPROFILESERVICE, false];
WSops.GetUserProfileByIndex = [USERPROFILESERVICE, false];
WSops.GetUserProfileByName = [USERPROFILESERVICE, false];
WSops.GetUserProfileCount = [USERPROFILESERVICE, false];
WSops.GetUserProfileSchema = [USERPROFILESERVICE, false];
WSops.GetUserPropertyByAccountName = [USERPROFILESERVICE, false];
WSops.ModifyUserPropertyByAccountName = [USERPROFILESERVICE, true];
WSops.RemoveAllColleagues = [USERPROFILESERVICE, true];
WSops.RemoveAllLinks = [USERPROFILESERVICE, true];
WSops.RemoveAllMemberships = [USERPROFILESERVICE, true];
WSops.RemoveAllPinnedLinks = [USERPROFILESERVICE, true];
WSops.RemoveColleague = [USERPROFILESERVICE, true];
WSops.RemoveLink = [USERPROFILESERVICE, true];
WSops.RemoveMembership = [USERPROFILESERVICE, true];
WSops.RemovePinnedLink = [USERPROFILESERVICE, true];
WSops.UpdateColleaguePrivacy = [USERPROFILESERVICE, true];
WSops.UpdateLink = [USERPROFILESERVICE, true];
WSops.UpdateMembershipPrivacy = [USERPROFILESERVICE, true];
WSops.UpdatePinnedLink = [USERPROFILESERVICE, true];
WSops.DeleteAllVersions = [VERSIONS, true];
WSops.DeleteVersion = [VERSIONS, true];
WSops.GetVersions = [VERSIONS, false];
WSops.RestoreVersion = [VERSIONS, true];
WSops.AddView = [VIEWS, true];
WSops.DeleteView = [VIEWS, true];
WSops.GetView = [VIEWS, false];
WSops.GetViewHtml = [VIEWS, false];
WSops.GetViewCollection = [VIEWS, false];
WSops.UpdateView = [VIEWS, true];
WSops.UpdateViewHtml = [VIEWS, true];
WSops.AddWebPart = [WEBPARTPAGES, true];
WSops.AddWebPartToZone = [WEBPARTPAGES, true];
WSops.DeleteWebPart = [WEBPARTPAGES, true];
WSops.GetWebPart2 = [WEBPARTPAGES, false];
WSops.GetWebPartPage = [WEBPARTPAGES, false];
WSops.GetWebPartProperties = [WEBPARTPAGES, false];
WSops.GetWebPartProperties2 = [WEBPARTPAGES, false];
WSops.SaveWebPart2 = [WEBPARTPAGES, true];
WSops.CreateContentType = [WEBS, true];
WSops.GetColumns = [WEBS, false];
WSops.GetContentType = [WEBS, false];
WSops.GetContentTypes = [WEBS, false];
WSops.GetCustomizedPageStatus = [WEBS, false];
WSops.GetListTemplates = [WEBS, false];
WSops.GetObjectIdFromUrl = [WEBS, false]; // 2010
WSops.GetWeb = [WEBS, false];
WSops.GetWebCollection = [WEBS, false];
WSops.GetAllSubWebCollection = [WEBS, false];
WSops.UpdateColumns = [WEBS, true];
WSops.UpdateContentType = [WEBS, true];
WSops.WebUrlFromPageUrl = [WEBS, false];
WSops.AlterToDo = [WORKFLOW, true];
WSops.ClaimReleaseTask = [WORKFLOW, true];
WSops.GetTemplatesForItem = [WORKFLOW, false];
WSops.GetToDosForItem = [WORKFLOW, false];
WSops.GetWorkflowDataForItem = [WORKFLOW, false];
WSops.GetWorkflowTaskData = [WORKFLOW, false];
WSops.StartWorkflow = [WORKFLOW, true];
// Set up SOAP envelope
var SOAPEnvelope = {};
SOAPEnvelope.header = "";
SOAPEnvelope.footer = "";
SOAPEnvelope.payload = "";
var SOAPAction;
// Main function, which calls SharePoint's Web Services directly.
$.fn.SPServices = function (options) {
// If there are no options passed in, use the defaults. Extend replaces each default with the passed option.
var opt = $.extend({}, $.fn.SPServices.defaults, options);
// Encode options which may contain special character, esp. ampersand
for (var i = 0; i < encodeOptionList.length; i++) {
if (typeof opt[encodeOptionList[i]] === "string") {
opt[encodeOptionList[i]] = encodeXml(opt[encodeOptionList[i]]);
}
}
// Put together operation header and SOAPAction for the SOAP call based on which Web Service we're calling
SOAPEnvelope.opheader = "<" + opt.operation + " ";
switch (WSops[opt.operation][0]) {
case ALERTS:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/2002/1/alerts/' >";
SOAPAction = SCHEMASharePoint + "/soap/2002/1/alerts/";
break;
case MEETINGS:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/meetings/' >";
SOAPAction = SCHEMASharePoint + "/soap/meetings/";
break;
case OFFICIALFILE:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/recordsrepository/' >";
SOAPAction = SCHEMASharePoint + "/soap/recordsrepository/";
break;
case PERMISSIONS:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/directory/' >";
SOAPAction = SCHEMASharePoint + "/soap/directory/";
break;
case PUBLISHEDLINKSSERVICE:
SOAPEnvelope.opheader += "xmlns='http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService/' >";
SOAPAction = "http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService/";
break;
case SEARCH:
SOAPEnvelope.opheader += "xmlns='urn:Microsoft.Search' >";
SOAPAction = "urn:Microsoft.Search/";
break;
case SHAREPOINTDIAGNOSTICS:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/diagnostics/' >";
SOAPAction = "http://schemas.microsoft.com/sharepoint/diagnostics/";
break;
case SOCIALDATASERVICE:
SOAPEnvelope.opheader += "xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService' >";
SOAPAction = "http://microsoft.com/webservices/SharePointPortalServer/SocialDataService/";
break;
case SPELLCHECK:
SOAPEnvelope.opheader += "xmlns='http://schemas.microsoft.com/sharepoint/publishing/spelling/' >";
SOAPAction = "http://schemas.microsoft.com/sharepoint/publishing/spelling/SpellCheck";
break;
case TAXONOMYSERVICE:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/taxonomy/soap/' >";
SOAPAction = SCHEMASharePoint + "/taxonomy/soap/";
break;
case USERGROUP:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/directory/' >";
SOAPAction = SCHEMASharePoint + "/soap/directory/";
break;
case USERPROFILESERVICE:
SOAPEnvelope.opheader += "xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService' >";
SOAPAction = "http://microsoft.com/webservices/SharePointPortalServer/UserProfileService/";
break;
case WEBPARTPAGES:
SOAPEnvelope.opheader += "xmlns='http://microsoft.com/sharepoint/webpartpages' >";
SOAPAction = "http://microsoft.com/sharepoint/webpartpages/";
break;
case WORKFLOW:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/workflow/' >";
SOAPAction = SCHEMASharePoint + "/soap/workflow/";
break;
default:
SOAPEnvelope.opheader += "xmlns='" + SCHEMASharePoint + "/soap/'>";
SOAPAction = SCHEMASharePoint + "/soap/";
break;
}
// Add the operation to the SOAPAction and opfooter
SOAPAction += opt.operation;
SOAPEnvelope.opfooter = "" + opt.operation + ">";
// Build the URL for the Ajax call based on which operation we're calling
// If the webURL has been provided, then use it, else use the current site
var ajaxURL = "_vti_bin/" + WSops[opt.operation][0] + ".asmx";
var thisSite = $().SPServices.SPGetCurrentSite();
var webURL = opt.webURL !== undefined ? opt.webURL : opt.webUrl;
if (webURL.charAt(webURL.length - 1) === SLASH) {
ajaxURL = webURL + ajaxURL;
} else if (webURL.length > 0) {
ajaxURL = webURL + SLASH + ajaxURL;
} else {
ajaxURL = thisSite + ((thisSite.charAt(thisSite.length - 1) === SLASH) ? ajaxURL : (SLASH + ajaxURL));
}
SOAPEnvelope.payload = "";
// Each operation requires a different set of values. This switch statement sets them up in the SOAPEnvelope.payload.
switch (opt.operation) {
// ALERT OPERATIONS
case "GetAlerts":
break;
case "DeleteAlerts":
SOAPEnvelope.payload += "";
for (i = 0; i < opt.IDs.length; i++) {
SOAPEnvelope.payload += wrapNode("string", opt.IDs[i]);
}
SOAPEnvelope.payload += "";
break;
// AUTHENTICATION OPERATIONS
case "Mode":
break;
case "Login":
addToPayload(opt, ["username", "password"]);
break;
// COPY OPERATIONS
case "CopyIntoItems":
addToPayload(opt, ["SourceUrl"]);
SOAPEnvelope.payload += "";
for (i = 0; i < opt.DestinationUrls.length; i++) {
SOAPEnvelope.payload += wrapNode("string", opt.DestinationUrls[i]);
}
SOAPEnvelope.payload += "";
addToPayload(opt, ["Fields", "Stream", "Results"]);
break;
case "CopyIntoItemsLocal":
addToPayload(opt, ["SourceUrl"]);
SOAPEnvelope.payload += "";
for (i = 0; i < opt.DestinationUrls.length; i++) {
SOAPEnvelope.payload += wrapNode("string", opt.DestinationUrls[i]);
}
SOAPEnvelope.payload += "";
break;
case "GetItem":
addToPayload(opt, ["Url", "Fields", "Stream"]);
break;
// FORM OPERATIONS
case "GetForm":
addToPayload(opt, ["listName", "formUrl"]);
break;
case "GetFormCollection":
addToPayload(opt, ["listName"]);
break;
// LIST OPERATIONS
case "AddAttachment":
addToPayload(opt, ["listName", "listItemID", "fileName", "attachment"]);
break;
case "AddDiscussionBoardItem":
addToPayload(opt, ["listName", "message"]);
break;
case "AddList":
addToPayload(opt, ["listName", "description", "templateID"]);
break;
case "AddListFromFeature":
addToPayload(opt, ["listName", "description", "featureID", "templateID"]);
break;
case "ApplyContentTypeToList":
addToPayload(opt, ["webUrl", "contentTypeId", "listName"]);
break;
case "CheckInFile":
addToPayload(opt, ["pageUrl", "comment", "CheckinType"]);
break;
case "CheckOutFile":
addToPayload(opt, ["pageUrl", "checkoutToLocal", "lastmodified"]);
break;
case "CreateContentType":
addToPayload(opt, ["listName", "displayName", "parentType", "fields", "contentTypeProperties", "addToView"]);
break;
case "DeleteAttachment":
addToPayload(opt, ["listName", "listItemID", "url"]);
break;
case "DeleteContentType":
addToPayload(opt, ["listName", "contentTypeId"]);
break;
case "DeleteContentTypeXmlDocument":
addToPayload(opt, ["listName", "contentTypeId", "documentUri"]);
break;
case "DeleteList":
addToPayload(opt, ["listName"]);
break;
case "GetAttachmentCollection":
addToPayload(opt, ["listName", ["listItemID", "ID"]]);
break;
case "GetList":
addToPayload(opt, ["listName"]);
break;
case "GetListAndView":
addToPayload(opt, ["listName", "viewName"]);
break;
case "GetListCollection":
break;
case "GetListContentType":
addToPayload(opt, ["listName", "contentTypeId"]);
break;
case "GetListContentTypes":
addToPayload(opt, ["listName"]);
break;
case "GetListItems":
addToPayload(opt, ["listName", "viewName", ["query", "CAMLQuery"],
["viewFields", "CAMLViewFields"],
["rowLimit", "CAMLRowLimit"],
["queryOptions", "CAMLQueryOptions"]
]);
break;
case "GetListItemChanges":
addToPayload(opt, ["listName", "viewFields", "since", "contains"]);
break;
case "GetListItemChangesSinceToken":
addToPayload(opt, ["listName", "viewName", ["query", "CAMLQuery"],
["viewFields", "CAMLViewFields"],
["rowLimit", "CAMLRowLimit"],
["queryOptions", "CAMLQueryOptions"], {
name: "changeToken",
sendNull: false
}, {
name: "contains",
sendNull: false
}
]);
break;
case "GetVersionCollection":
addToPayload(opt, ["strlistID", "strlistItemID", "strFieldName"]);
break;
case "UndoCheckOut":
addToPayload(opt, ["pageUrl"]);
break;
case "UpdateContentType":
addToPayload(opt, ["listName", "contentTypeId", "contentTypeProperties", "newFields", "updateFields", "deleteFields", "addToView"]);
break;
case "UpdateContentTypesXmlDocument":
addToPayload(opt, ["listName", "newDocument"]);
break;
case "UpdateContentTypeXmlDocument":
addToPayload(opt, ["listName", "contentTypeId", "newDocument"]);
break;
case "UpdateList":
addToPayload(opt, ["listName", "listProperties", "newFields", "updateFields", "deleteFields", "listVersion"]);
break;
case "UpdateListItems":
addToPayload(opt, ["listName"]);
if (typeof opt.updates !== "undefined" && opt.updates.length > 0) {
addToPayload(opt, ["updates"]);
} else {
SOAPEnvelope.payload += "";
for (i = 0; i < opt.valuepairs.length; i++) {
SOAPEnvelope.payload += "" + escapeColumnValue(opt.valuepairs[i][1]) + "";
}
if (opt.batchCmd !== "New") {
SOAPEnvelope.payload += "" + opt.ID + "";
}
SOAPEnvelope.payload += "";
}
break;
// MEETINGS OPERATIONS
case "AddMeeting":
addToPayload(opt, ["organizerEmail", "uid", "sequence", "utcDateStamp", "title", "location", "utcDateStart", "utcDateEnd", "nonGregorian"]);
break;
case "CreateWorkspace":
addToPayload(opt, ["title", "templateName", "lcid", "timeZoneInformation"]);
break;
case "RemoveMeeting":
addToPayload(opt, ["recurrenceId", "uid", "sequence", "utcDateStamp", "cancelMeeting"]);
break;
case "SetWorkspaceTitle":
addToPayload(opt, ["title"]);
break;
// OFFICIALFILE OPERATIONS
case "GetRecordRouting":
addToPayload(opt, ["recordRouting"]);
break;
case "GetRecordRoutingCollection":
break;
case "GetServerInfo":
break;
case "SubmitFile":
addToPayload(opt, ["fileToSubmit"], ["properties"], ["recordRouting"], ["sourceUrl"], ["userName"]);
break;
// PEOPLE OPERATIONS
case "ResolvePrincipals":
addToPayload(opt, ["principalKeys", "principalType", "addToUserInfoList"]);
break;
case "SearchPrincipals":
addToPayload(opt, ["searchText", "maxResults", "principalType"]);
break;
// PERMISSION OPERATIONS
case "AddPermission":
addToPayload(opt, ["objectName", "objectType", "permissionIdentifier", "permissionType", "permissionMask"]);
break;
case "AddPermissionCollection":
addToPayload(opt, ["objectName", "objectType", "permissionsInfoXml"]);
break;
case "GetPermissionCollection":
addToPayload(opt, ["objectName", "objectType"]);
break;
case "RemovePermission":
addToPayload(opt, ["objectName", "objectType", "permissionIdentifier", "permissionType"]);
break;
case "RemovePermissionCollection":
addToPayload(opt, ["objectName", "objectType", "memberIdsXml"]);
break;
case "UpdatePermission":
addToPayload(opt, ["objectName", "objectType", "permissionIdentifier", "permissionType", "permissionMask"]);
break;
// PUBLISHEDLINKSSERVICE OPERATIONS
case "GetLinks":
break;
// SEARCH OPERATIONS
case "GetPortalSearchInfo":
SOAPEnvelope.opheader = "<" + opt.operation + " xmlns='http://microsoft.com/webservices/OfficeServer/QueryService'>";
SOAPAction = "http://microsoft.com/webservices/OfficeServer/QueryService/" + opt.operation;
break;
case "GetQuerySuggestions":
SOAPEnvelope.opheader = "<" + opt.operation + " xmlns='http://microsoft.com/webservices/OfficeServer/QueryService'>";
SOAPAction = "http://microsoft.com/webservices/OfficeServer/QueryService/" + opt.operation;
SOAPEnvelope.payload += wrapNode("queryXml", encodeXml(opt.queryXml));
break;
case "GetSearchMetadata":
SOAPEnvelope.opheader = "<" + opt.operation + " xmlns='http://microsoft.com/webservices/OfficeServer/QueryService'>";
SOAPAction = "http://microsoft.com/webservices/OfficeServer/QueryService/" + opt.operation;
break;
case "Query":
SOAPEnvelope.payload += wrapNode("queryXml", encodeXml(opt.queryXml));
break;
case "QueryEx":
SOAPEnvelope.opheader = "<" + opt.operation + " xmlns='http://microsoft.com/webservices/OfficeServer/QueryService'>";
SOAPAction = "http://microsoft.com/webservices/OfficeServer/QueryService/" + opt.operation;
SOAPEnvelope.payload += wrapNode("queryXml", encodeXml(opt.queryXml));
break;
case "Registration":
SOAPEnvelope.payload += wrapNode("registrationXml", encodeXml(opt.registrationXml));
break;
case "Status":
break;
// SHAREPOINTDIAGNOSTICS OPERATIONS
case "SendClientScriptErrorReport":
addToPayload(opt, ["message", "file", "line", "client", "stack", "team", "originalFile"]);
break;
// SITEDATA OPERATIONS
case "EnumerateFolder":
addToPayload(opt, ["strFolderUrl"]);
break;
case "GetAttachments":
addToPayload(opt, ["strListName", "strItemId"]);
break;
case "SiteDataGetList":
addToPayload(opt, ["strListName"]);
// Because this operation has a name which duplicates the Lists WS, need to handle
SOAPEnvelope = siteDataFixSOAPEnvelope(SOAPEnvelope, opt.operation);
break;
case "SiteDataGetListCollection":
// Because this operation has a name which duplicates the Lists WS, need to handle
SOAPEnvelope = siteDataFixSOAPEnvelope(SOAPEnvelope, opt.operation);
break;
case "SiteDataGetSite":
// Because this operation has a name which duplicates the Lists WS, need to handle
SOAPEnvelope = siteDataFixSOAPEnvelope(SOAPEnvelope, opt.operation);
break;
case "SiteDataGetSiteUrl":
addToPayload(opt, ["Url"]);
// Because this operation has a name which duplicates the Lists WS, need to handle
SOAPEnvelope = siteDataFixSOAPEnvelope(SOAPEnvelope, opt.operation);
break;
case "SiteDataGetWeb":
// Because this operation has a name which duplicates the Lists WS, need to handle
SOAPEnvelope = siteDataFixSOAPEnvelope(SOAPEnvelope, opt.operation);
break;
// SITES OPERATIONS
case "CreateWeb":
addToPayload(opt, ["url", "title", "description", "templateName", "language", "languageSpecified",
"locale", "localeSpecified", "collationLocale", "collationLocaleSpecified", "uniquePermissions",
"uniquePermissionsSpecified", "anonymous", "anonymousSpecified", "presence", "presenceSpecified"
]);
break;
case "DeleteWeb":
addToPayload(opt, ["url"]);
break;
case "GetSite":
addToPayload(opt, ["SiteUrl"]);
break;
case "GetSiteTemplates":
addToPayload(opt, ["LCID", "TemplateList"]);
break;
// SOCIALDATASERVICE OPERATIONS
case "AddComment":
addToPayload(opt, ["url", "comment", "isHighPriority", "title"]);
break;
case "AddTag":
addToPayload(opt, ["url", "termID", "title", "isPrivate"]);
break;
case "AddTagByKeyword":
addToPayload(opt, ["url", "keyword", "title", "isPrivate"]);
break;
case "CountCommentsOfUser":
addToPayload(opt, ["userAccountName"]);
break;
case "CountCommentsOfUserOnUrl":
addToPayload(opt, ["userAccountName", "url"]);
break;
case "CountCommentsOnUrl":
addToPayload(opt, ["url"]);
break;
case "CountRatingsOnUrl":
addToPayload(opt, ["url"]);
break;
case "CountTagsOfUser":
addToPayload(opt, ["userAccountName"]);
break;
case "DeleteComment":
addToPayload(opt, ["url", "lastModifiedTime"]);
break;
case "DeleteRating":
addToPayload(opt, ["url"]);
break;
case "DeleteTag":
addToPayload(opt, ["url", "termID"]);
break;
case "DeleteTagByKeyword":
addToPayload(opt, ["url", "keyword"]);
break;
case "DeleteTags":
addToPayload(opt, ["url"]);
break;
case "GetAllTagTerms":
addToPayload(opt, ["maximumItemsToReturn"]);
break;
case "GetAllTagTermsForUrlFolder":
addToPayload(opt, ["urlFolder", "maximumItemsToReturn"]);
break;
case "GetAllTagUrls":
addToPayload(opt, ["termID"]);
break;
case "GetAllTagUrlsByKeyword":
addToPayload(opt, ["keyword"]);
break;
case "GetCommentsOfUser":
addToPayload(opt, ["userAccountName", "maximumItemsToReturn", "startIndex"]);
break;
case "GetCommentsOfUserOnUrl":
addToPayload(opt, ["userAccountName", "url"]);
break;
case "GetCommentsOnUrl":
addToPayload(opt, ["url", "maximumItemsToReturn", "startIndex"]);
if (typeof opt.excludeItemsTime !== "undefined" && opt.excludeItemsTime.length > 0) {
SOAPEnvelope.payload += wrapNode("excludeItemsTime", opt.excludeItemsTime);
}
break;
case "GetRatingAverageOnUrl":
addToPayload(opt, ["url"]);
break;
case "GetRatingOfUserOnUrl":
addToPayload(opt, ["userAccountName", "url"]);
break;
case "GetRatingOnUrl":
addToPayload(opt, ["url"]);
break;
case "GetRatingsOfUser":
addToPayload(opt, ["userAccountName"]);
break;
case "GetRatingsOnUrl":
addToPayload(opt, ["url"]);
break;
case "GetSocialDataForFullReplication":
addToPayload(opt, ["userAccountName"]);
break;
case "GetTags":
addToPayload(opt, ["url"]);
break;
case "GetTagsOfUser":
addToPayload(opt, ["userAccountName", "maximumItemsToReturn", "startIndex"]);
break;
case "GetTagTerms":
addToPayload(opt, ["maximumItemsToReturn"]);
break;
case "GetTagTermsOfUser":
addToPayload(opt, ["userAccountName", "maximumItemsToReturn"]);
break;
case "GetTagTermsOnUrl":
addToPayload(opt, ["url", "maximumItemsToReturn"]);
break;
case "GetTagUrls":
addToPayload(opt, ["termID"]);
break;
case "GetTagUrlsByKeyword":
addToPayload(opt, ["keyword"]);
break;
case "GetTagUrlsOfUser":
addToPayload(opt, ["termID", "userAccountName"]);
break;
case "GetTagUrlsOfUserByKeyword":
addToPayload(opt, ["keyword", "userAccountName"]);
break;
case "SetRating":
addToPayload(opt, ["url", "rating", "title", "analysisDataEntry"]);
break;
case "UpdateComment":
addToPayload(opt, ["url", "lastModifiedTime", "comment", "isHighPriority"]);
break;
// SPELLCHECK OPERATIONS
case "SpellCheck":
addToPayload(opt, ["chunksToSpell", "declaredLanguage", "useLad"]);
break;
// TAXONOMY OPERATIONS
case "AddTerms":
addToPayload(opt, ["sharedServiceId", "termSetId", "lcid", "newTerms"]);
break;
case "GetChildTermsInTerm":
addToPayload(opt, ["sspId", "lcid", "termId", "termSetId"]);
break;
case "GetChildTermsInTermSet":
addToPayload(opt, ["sspId", "lcid", "termSetId"]);
break;
case "GetKeywordTermsByGuids":
addToPayload(opt, ["termIds", "lcid"]);
break;
case "GetTermsByLabel":
addToPayload(opt, ["label", "lcid", "matchOption", "resultCollectionSize", "termIds", "addIfNotFound"]);
break;
case "GetTermSets":
addToPayload(opt, ["sharedServiceIds", "termSetIds", "lcid", "clientTimeStamps", "clientVersions"]);
break;
// USERS AND GROUPS OPERATIONS
case "AddGroup":
addToPayload(opt, ["groupName", "ownerIdentifier", "ownerType", "defaultUserLoginName", "description"]);
break;
case "AddGroupToRole":
addToPayload(opt, ["groupName", "roleName"]);
break;
case "AddRole":
addToPayload(opt, ["roleName", "description", "permissionMask"]);
break;
case "AddRoleDef":
addToPayload(opt, ["roleName", "description", "permissionMask"]);
break;
case "AddUserCollectionToGroup":
addToPayload(opt, ["groupName", "usersInfoXml"]);
break;
case "AddUserCollectionToRole":
addToPayload(opt, ["roleName", "usersInfoXml"]);
break;
case "AddUserToGroup":
addToPayload(opt, ["groupName", "userName", "userLoginName", "userEmail", "userNotes"]);
break;
case "AddUserToRole":
addToPayload(opt, ["roleName", "userName", "userLoginName", "userEmail", "userNotes"]);
break;
case "GetAllUserCollectionFromWeb":
break;
case "GetGroupCollection":
addToPayload(opt, ["groupNamesXml"]);
break;
case "GetGroupCollectionFromRole":
addToPayload(opt, ["roleName"]);
break;
case "GetGroupCollectionFromSite":
break;
case "GetGroupCollectionFromUser":
addToPayload(opt, ["userLoginName"]);
break;
case "GetGroupCollectionFromWeb":
break;
case "GetGroupInfo":
addToPayload(opt, ["groupName"]);
break;
case "GetRoleCollection":
addToPayload(opt, ["roleNamesXml"]);
break;
case "GetRoleCollectionFromGroup":
addToPayload(opt, ["groupName"]);
break;
case "GetRoleCollectionFromUser":
addToPayload(opt, ["userLoginName"]);
break;
case "GetRoleCollectionFromWeb":
break;
case "GetRoleInfo":
addToPayload(opt, ["roleName"]);
break;
case "GetRolesAndPermissionsForCurrentUser":
break;
case "GetRolesAndPermissionsForSite":
break;
case "GetUserCollection":
addToPayload(opt, ["userLoginNamesXml"]);
break;
case "GetUserCollectionFromGroup":
addToPayload(opt, ["groupName"]);
break;
case "GetUserCollectionFromRole":
addToPayload(opt, ["roleName"]);
break;
case "GetUserCollectionFromSite":
break;
case "GetUserCollectionFromWeb":
break;
case "GetUserInfo":
addToPayload(opt, ["userLoginName"]);
break;
case "GetUserLoginFromEmail":
addToPayload(opt, ["emailXml"]);
break;
case "RemoveGroup":
addToPayload(opt, ["groupName"]);
break;
case "RemoveGroupFromRole":
addToPayload(opt, ["roleName", "groupName"]);
break;
case "RemoveRole":
addToPayload(opt, ["roleName"]);
break;
case "RemoveUserCollectionFromGroup":
addToPayload(opt, ["groupName", "userLoginNamesXml"]);
break;
case "RemoveUserCollectionFromRole":
addToPayload(opt, ["roleName", "userLoginNamesXml"]);
break;
case "RemoveUserCollectionFromSite":
addToPayload(opt, ["userLoginNamesXml"]);
break;
case "RemoveUserFromGroup":
addToPayload(opt, ["groupName", "userLoginName"]);
break;
case "RemoveUserFromRole":
addToPayload(opt, ["roleName", "userLoginName"]);
break;
case "RemoveUserFromSite":
addToPayload(opt, ["userLoginName"]);
break;
case "RemoveUserFromWeb":
addToPayload(opt, ["userLoginName"]);
break;
case "UpdateGroupInfo":
addToPayload(opt, ["oldGroupName", "groupName", "ownerIdentifier", "ownerType", "description"]);
break;
case "UpdateRoleDefInfo":
addToPayload(opt, ["oldRoleName", "roleName", "description", "permissionMask"]);
break;
case "UpdateRoleInfo":
addToPayload(opt, ["oldRoleName", "roleName", "description", "permissionMask"]);
break;
case "UpdateUserInfo":
addToPayload(opt, ["userLoginName", "userName", "userEmail", "userNotes"]);
break;
// USERPROFILESERVICE OPERATIONS
case "AddColleague":
addToPayload(opt, ["accountName", "colleagueAccountName", "group", "privacy", "isInWorkGroup"]);
break;
case "AddLink":
addToPayload(opt, ["accountName", "name", "url", "group", "privacy"]);
break;
case "AddMembership":
addToPayload(opt, ["accountName", "membershipInfo", "group", "privacy"]);
break;
case "AddPinnedLink":
addToPayload(opt, ["accountName", "name", "url"]);
break;
case "CreateMemberGroup":
addToPayload(opt, ["membershipInfo"]);
break;
case "CreateUserProfileByAccountName":
addToPayload(opt, ["accountName"]);
break;
case "GetCommonColleagues":
addToPayload(opt, ["accountName"]);
break;
case "GetCommonManager":
addToPayload(opt, ["accountName"]);
break;
case "GetCommonMemberships":
addToPayload(opt, ["accountName"]);
break;
case "GetInCommon":
addToPayload(opt, ["accountName"]);
break;
case "GetPropertyChoiceList":
addToPayload(opt, ["propertyName"]);
break;
case "GetUserColleagues":
addToPayload(opt, ["accountName"]);
break;
case "GetUserLinks":
addToPayload(opt, ["accountName"]);
break;
case "GetUserMemberships":
addToPayload(opt, ["accountName"]);
break;
case "GetUserPinnedLinks":
addToPayload(opt, ["accountName"]);
break;
case "GetUserProfileByGuid":
addToPayload(opt, ["guid"]);
break;
case "GetUserProfileByIndex":
addToPayload(opt, ["index"]);
break;
case "GetUserProfileByName":
// Note that this operation is inconsistent with the others, using AccountName rather than accountName
if (typeof opt.accountName !== "undefined" && opt.accountName.length > 0) {
addToPayload(opt, [
["AccountName", "accountName"]
]);
} else {
addToPayload(opt, ["AccountName"]);
}
break;
case "GetUserProfileCount":
break;
case "GetUserProfileSchema":
break;
case "GetUserPropertyByAccountName":
addToPayload(opt, ["accountName", "propertyName"]);
break;
case "ModifyUserPropertyByAccountName":
addToPayload(opt, ["accountName", "newData"]);
break;
case "RemoveAllColleagues":
addToPayload(opt, ["accountName"]);
break;
case "RemoveAllLinks":
addToPayload(opt, ["accountName"]);
break;
case "RemoveAllMemberships":
addToPayload(opt, ["accountName"]);
break;
case "RemoveAllPinnedLinks":
addToPayload(opt, ["accountName"]);
break;
case "RemoveColleague":
addToPayload(opt, ["accountName", "colleagueAccountName"]);
break;
case "RemoveLink":
addToPayload(opt, ["accountName", "id"]);
break;
case "RemoveMembership":
addToPayload(opt, ["accountName", "sourceInternal", "sourceReference"]);
break;
case "RemovePinnedLink":
addToPayload(opt, ["accountName", "id"]);
break;
case "UpdateColleaguePrivacy":
addToPayload(opt, ["accountName", "colleagueAccountName", "newPrivacy"]);
break;
case "UpdateLink":
addToPayload(opt, ["accountName", "data"]);
break;
case "UpdateMembershipPrivacy":
addToPayload(opt, ["accountName", "sourceInternal", "sourceReference", "newPrivacy"]);
break;
case "UpdatePinnedLink ":
addToPayload(opt, ["accountName", "data"]);
break;
// VERSIONS OPERATIONS
case "DeleteAllVersions":
addToPayload(opt, ["fileName"]);
break;
case "DeleteVersion":
addToPayload(opt, ["fileName", "fileVersion"]);
break;
case "GetVersions":
addToPayload(opt, ["fileName"]);
break;
case "RestoreVersion":
addToPayload(opt, ["fileName", "fileVersion"]);
break;
// VIEW OPERATIONS
case "AddView":
addToPayload(opt, ["listName", "viewName", "viewFields", "query", "rowLimit", "rowLimit", "type", "makeViewDefault"]);
break;
case "DeleteView":
addToPayload(opt, ["listName", "viewName"]);
break;
case "GetView":
addToPayload(opt, ["listName", "viewName"]);
break;
case "GetViewCollection":
addToPayload(opt, ["listName"]);
break;
case "GetViewHtml":
addToPayload(opt, ["listName", "viewName"]);
break;
case "UpdateView":
addToPayload(opt, ["listName", "viewName", "viewProperties", "query", "viewFields", "aggregations", "formats", "rowLimit"]);
break;
case "UpdateViewHtml":
addToPayload(opt, ["listName", "viewName", "viewProperties", "toolbar", "viewHeader", "viewBody", "viewFooter", "viewEmpty", "rowLimitExceeded",
"query", "viewFields", "aggregations", "formats", "rowLimit"
]);
break;
// WEBPARTPAGES OPERATIONS
case "AddWebPart":
addToPayload(opt, ["pageUrl", "webPartXml", "storage"]);
break;
case "AddWebPartToZone":
addToPayload(opt, ["pageUrl", "webPartXml", "storage", "zoneId", "zoneIndex"]);
break;
case "DeleteWebPart":
addToPayload(opt, ["pageUrl", "storageKey", "storage"]);
break;
case "GetWebPart2":
addToPayload(opt, ["pageUrl", "storageKey", "storage", "behavior"]);
break;
case "GetWebPartPage":
addToPayload(opt, ["documentName", "behavior"]);
break;
case "GetWebPartProperties":
addToPayload(opt, ["pageUrl", "storage"]);
break;
case "GetWebPartProperties2":
addToPayload(opt, ["pageUrl", "storage", "behavior"]);
break;
case "SaveWebPart2":
addToPayload(opt, ["pageUrl", "storageKey", "webPartXml", "storage", "allowTypeChange"]);
break;
// WEBS OPERATIONS
case "Webs.CreateContentType":
addToPayload(opt, ["displayName", "parentType", "newFields", "contentTypeProperties"]);
break;
case "GetColumns":
addToPayload(opt, ["webUrl"]);
break;
case "GetContentType":
addToPayload(opt, ["contentTypeId"]);
break;
case "GetContentTypes":
break;
case "GetCustomizedPageStatus":
addToPayload(opt, ["fileUrl"]);
break;
case "GetListTemplates":
break;
case "GetObjectIdFromUrl":
addToPayload(opt, ["objectUrl"]);
break;
case "GetWeb":
addToPayload(opt, [
["webUrl", "webURL"]
]);
break;
case "GetWebCollection":
break;
case "GetAllSubWebCollection":
break;
case "UpdateColumns":
addToPayload(opt, ["newFields", "updateFields", "deleteFields"]);
break;
case "Webs.UpdateContentType":
addToPayload(opt, ["contentTypeId", "contentTypeProperties", "newFields", "updateFields", "deleteFields"]);
break;
case "WebUrlFromPageUrl":
addToPayload(opt, [
["pageUrl", "pageURL"]
]);
break;
// WORKFLOW OPERATIONS
case "AlterToDo":
addToPayload(opt, ["item", "todoId", "todoListId", "taskData"]);
break;
case "ClaimReleaseTask":
addToPayload(opt, ["item", "taskId", "listId", "fClaim"]);
break;
case "GetTemplatesForItem":
addToPayload(opt, ["item"]);
break;
case "GetToDosForItem":
addToPayload(opt, ["item"]);
break;
case "GetWorkflowDataForItem":
addToPayload(opt, ["item"]);
break;
case "GetWorkflowTaskData":
addToPayload(opt, ["item", "listId", "taskId"]);
break;
case "StartWorkflow":
addToPayload(opt, ["item", "templateId", "workflowParameters"]);
break;
default:
break;
}
// Glue together the pieces of the SOAP message
var msg = SOAPEnvelope.header + SOAPEnvelope.opheader + SOAPEnvelope.payload + SOAPEnvelope.opfooter + SOAPEnvelope.footer;
// Check to see if we've already cached the results
var cachedPromise;
if (opt.cacheXML) {
cachedPromise = promisesCache[msg];
}
if (typeof cachedPromise === "undefined") {
// Finally, make the Ajax call
var p = $.ajax({
// The relative URL for the AJAX call
url: ajaxURL,
// By default, the AJAX calls are asynchronous. You can specify false to require a synchronous call.
async: opt.async,
// Before sending the msg, need to send the request header
beforeSend: function (xhr) {
// If we need to pass the SOAPAction, do so
if (WSops[opt.operation][1]) {
xhr.setRequestHeader("SOAPAction", SOAPAction);
}
},
// Always a POST
type: "POST",
// Here is the SOAP request we've built above
data: msg,
// We're getting XML; tell jQuery so that it doesn't need to do a best guess
dataType: "xml",
// and this is its content type
contentType: "text/xml;charset='utf-8'",
complete: function (xData, Status) {
// When the call is complete, call the completefunc if there is one
if ($.isFunction(opt.completefunc)) {
opt.completefunc(xData, Status);
}
}
});
if(opt.cacheXML) {
promisesCache[msg] = p;
}
// Return the promise
return p;
} else {
// Call the completefunc if there is one
if ($.isFunction(opt.completefunc)) {
// opt.completefunc(cachedPromise, null);
cachedPromise.done(function(data, status, jqXHR){
opt.completefunc(jqXHR, status);
});
}
// Return the cached promise
return cachedPromise;
}
}; // End $.fn.SPServices
// Defaults added as a function in our library means that the caller can override the defaults
// for their session by calling this function. Each operation requires a different set of options;
// we allow for all in a standardized way.
$.fn.SPServices.defaults = {
cacheXML: false, // If true, we'll cache the XML results with jQuery's .data() function
operation: "", // The Web Service operation
webURL: "", // URL of the target Web
makeViewDefault: false, // true to make the view the default view for the list
// For operations requiring CAML, these options will override any abstractions
viewName: "", // View name in CAML format.
CAMLQuery: "", // Query in CAML format
CAMLViewFields: "", // View fields in CAML format
CAMLRowLimit: 0, // Row limit as a string representation of an integer
CAMLQueryOptions: "", // Query options in CAML format
// Abstractions for CAML syntax
batchCmd: "Update", // Method Cmd for UpdateListItems
valuepairs: [], // Fieldname / Fieldvalue pairs for UpdateListItems
// As of v0.7.1, removed all options which were assigned an empty string ("")
DestinationUrls: [], // Array of destination URLs for copy operations
behavior: "Version3", // An SPWebServiceBehavior indicating whether the client supports Windows SharePoint Services 2.0 or Windows SharePoint Services 3.0: {Version2 | Version3 }
storage: "Shared", // A Storage value indicating how the Web Part is stored: {None | Personal | Shared}
objectType: "List", // objectType for operations which require it
cancelMeeting: true, // true to delete a meeting;false to remove its association with a Meeting Workspace site
nonGregorian: false, // true if the calendar is set to a format other than Gregorian;otherwise, false.
fClaim: false, // Specifies if the action is a claim or a release. Specifies true for a claim and false for a release.
recurrenceId: 0, // The recurrence ID for the meeting that needs its association removed. This parameter can be set to 0 for single-instance meetings.
sequence: 0, // An integer that is used to determine the ordering of updates in case they arrive out of sequence. Updates with a lower-than-current sequence are discarded. If the sequence is equal to the current sequence, the latest update are applied.
maximumItemsToReturn: 0, // SocialDataService maximumItemsToReturn
startIndex: 0, // SocialDataService startIndex
isHighPriority: false, // SocialDataService isHighPriority
isPrivate: false, // SocialDataService isPrivate
rating: 1, // SocialDataService rating
maxResults: 10, // Unless otherwise specified, the maximum number of principals that can be returned from a provider is 10.
principalType: "User", // Specifies user scope and other information: [None | User | DistributionList | SecurityGroup | SharePointGroup | All]
async: true, // Allow the user to force async
completefunc: null // Function to call on completion
}; // End $.fn.SPServices.defaults
// Function to determine the current Web's URL. We need this for successful Ajax calls.
// The function is also available as a public function.
$.fn.SPServices.SPGetCurrentSite = function () {
// We've already determined the current site...
if (currentContext.thisSite.length > 0) {
return currentContext.thisSite;
}
// If we still don't know the current site, we call WebUrlFromPageUrlResult.
var msg = SOAPEnvelope.header +
"" +
((location.href.indexOf("?") > 0) ? location.href.substr(0, location.href.indexOf("?")) : location.href) +
"" +
SOAPEnvelope.footer;
$.ajax({
async: false, // Need this to be synchronous so we're assured of a valid value
url: "/_vti_bin/Webs.asmx",
type: "POST",
data: msg,
dataType: "xml",
contentType: "text/xml;charset=\"utf-8\"",
complete: function (xData) {
currentContext.thisSite = $(xData.responseXML).find("WebUrlFromPageUrlResult").text();
}
});
return currentContext.thisSite; // Return the URL
}; // End $.fn.SPServices.SPGetCurrentSite
// Function to set up cascading dropdowns on a SharePoint form
// (Newform.aspx, EditForm.aspx, or any other customized form.)
$.fn.SPServices.SPCascadeDropdowns = function (options) {
var opt = $.extend({}, {
relationshipWebURL: "", // [Optional] The name of the Web (site) which contains the relationships list
relationshipList: "", // The name of the list which contains the parent/child relationships
relationshipListParentColumn: "", // The internal name of the parent column in the relationship list
relationshipListChildColumn: "", // The internal name of the child column in the relationship list
relationshipListSortColumn: "", // [Optional] If specified, sort the options in the dropdown by this column,
// otherwise the options are sorted by relationshipListChildColumn
parentColumn: "", // The display name of the parent column in the form
childColumn: "", // The display name of the child column in the form
listName: $().SPServices.SPListNameFromUrl(), // The list the form is working with. This is useful if the form is not in the list context.
CAMLQuery: "", // [Optional] For power users, this CAML fragment will be Anded with the default query on the relationshipList
CAMLQueryOptions: "FALSE", // [Optional] For power users, ability to specify Query Options
promptText: "", // [DEPRECATED] Text to use as prompt. If included, {0} will be replaced with the value of childColumn. Original value "Choose {0}..."
noneText: "(None)", // [Optional] Text to use for the (None) selection. Provided for non-English language support.
simpleChild: false, // [Optional] If set to true and childColumn is a complex dropdown, convert it to a simple dropdown
selectSingleOption: false, // [Optional] If set to true and there is only a single child option, select it
matchOnId: false, // By default, we match on the lookup's text value. If matchOnId is true, we'll match on the lookup id instead.
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options);
var thisParentSetUp = false;
var thisFunction = "SPServices.SPCascadeDropdowns";
// Find the parent column's select (dropdown)
var parentSelect = $().SPServices.SPDropdownCtl({
displayName: opt.parentColumn
});
if (parentSelect.Obj.html() === null && opt.debug) {
errBox(thisFunction, "parentColumn: " + opt.parentColumn, TXTColumnNotFound);
return;
}
// Find the child column's select (dropdown)
var childSelect = $().SPServices.SPDropdownCtl({
displayName: opt.childColumn
});
if (childSelect.Obj.html() === null && opt.debug) {
errBox(thisFunction, "childColumn: " + opt.childColumn, TXTColumnNotFound);
return;
}
// If requested and the childColumn is a complex dropdown, convert to a simple dropdown
if (opt.simpleChild === true && childSelect.Type === dropdownType.complex) {
$().SPServices.SPComplexToSimpleDropdown({
listName: opt.listName,
columnName: opt.childColumn
});
// Set the childSelect to reference the new simple dropdown
childSelect = $().SPServices.SPDropdownCtl({
displayName: opt.childColumn
});
}
var childColumnRequired, childColumnStatic;
// Get information about the childColumn from the current list
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
listName: opt.listName,
completefunc: function (xData) {
$(xData.responseXML).find("Fields").each(function () {
$(this).find("Field[DisplayName='" + opt.childColumn + "']").each(function () {
// Determine whether childColumn is Required
childColumnRequired = ($(this).attr("Required") === "TRUE");
childColumnStatic = $(this).attr("StaticName");
// Stop looking; we're done
return false;
});
});
}
});
// Save data about each child column on the parent
var childColumn = {
opt: opt,
childSelect: childSelect,
childColumnStatic: childColumnStatic,
childColumnRequired: childColumnRequired
};
var childColumns = parentSelect.Obj.data("SPCascadeDropdownsChildColumns");
// If this is the first child for this parent, then create the data object to hold the settings
if (typeof childColumns === "undefined") {
parentSelect.Obj.data("SPCascadeDropdownsChildColumns", [childColumn]);
// If we already have a data object for this parent, then add the setting for this child to it
} else {
childColumns.push(childColumn);
parentSelect.Obj.data("SPCascadeDropdownsChildColumns", childColumns);
thisParentSetUp = true;
}
// We only need to bind to the event(s) if we haven't already done so
if (!thisParentSetUp) {
switch (parentSelect.Type) {
// Plain old select
case dropdownType.simple:
parentSelect.Obj.bind("change", function () {
cascadeDropdown(parentSelect);
});
break;
// Input / Select hybrid
case dropdownType.complex:
// Bind to any change on the hidden input element
parentSelect.optHid.bind("propertychange", function () {
cascadeDropdown(parentSelect);
});
break;
// Multi-select hybrid
case dropdownType.multiSelect:
// Handle the dblclick on the candidate select
$(parentSelect.master.candidateControl).bind("dblclick", function () {
cascadeDropdown(parentSelect);
});
// Handle the dblclick on the selected values
$(parentSelect.master.resultControl).bind("dblclick", function () {
cascadeDropdown(parentSelect);
});
// Handle button clicks
$(parentSelect.master.addControl).bind("click", function () {
cascadeDropdown(parentSelect);
});
$(parentSelect.master.removeControl).bind("click", function () {
cascadeDropdown(parentSelect);
});
break;
default:
break;
}
}
// Fire the change to set the initially allowable values
cascadeDropdown(parentSelect);
}; // End $.fn.SPServices.SPCascadeDropdowns
function cascadeDropdown(parentSelect) {
var choices = "";
var parentSelectSelected;
var childSelectSelected = null;
var newMultiLookupPickerdata;
var numChildOptions;
var firstChildOptionId;
var firstChildOptionValue;
// Filter each child column
var childColumns = parentSelect.Obj.data("SPCascadeDropdownsChildColumns");
$(childColumns).each(function () {
// Break out the data objects for this child column
var opt = this.opt;
var childSelect = this.childSelect;
var childColumnStatic = this.childColumnStatic;
var childColumnRequired = this.childColumnRequired;
// Get the parent column selection(s)
parentSelectSelected = getDropdownSelected(parentSelect, opt.matchOnId);
// If the selection hasn't changed, then there's nothing to do right now. This is useful to reduce
// the number of Web Service calls when the parentSelect.Type = dropdownType.complex or dropdownType.multiSelect, as there are multiple propertychanges
// which don't require any action. The attribute will be unique per child column in case there are
// multiple children for a given parent.
var allParentSelections = parentSelectSelected.join(spDelim);
if (parentSelect.Obj.data("SPCascadeDropdown_Selected_" + childColumnStatic) === allParentSelections) {
return;
}
parentSelect.Obj.data("SPCascadeDropdown_Selected_" + childColumnStatic, allParentSelections);
// Get the current child column selection(s)
childSelectSelected = getDropdownSelected(childSelect, true);
// When the parent column's selected option changes, get the matching items from the relationship list
// Get the list items which match the current selection
var sortColumn = (opt.relationshipListSortColumn.length > 0) ? opt.relationshipListSortColumn : opt.relationshipListChildColumn;
var camlQuery = "";
if (opt.CAMLQuery.length > 0) {
camlQuery += "";
}
// Build up the criteria for inclusion
if (parentSelectSelected.length === 0) {
// Handle the case where no values are selected in multi-selects
camlQuery += "";
} else if (parentSelectSelected.length === 1) {
// Only one value is selected
camlQuery += "" : "'/>") +
escapeColumnValue(parentSelectSelected[0]) + "";
} else {
var compound = (parentSelectSelected.length > 2);
for (i = 0; i < (parentSelectSelected.length - 1); i++) {
camlQuery += "";
}
for (i = 0; i < parentSelectSelected.length; i++) {
camlQuery += "" : "'/>") +
escapeColumnValue(parentSelectSelected[i]) + "";
if (i > 0 && (i < (parentSelectSelected.length - 1)) && compound) {
camlQuery += "";
}
}
camlQuery += "";
}
if (opt.CAMLQuery.length > 0) {
camlQuery += opt.CAMLQuery + "";
}
// Make sure we don't get any items which don't have the child value
camlQuery += "";
camlQuery += "";
$().SPServices({
operation: "GetListItems",
// Force sync so that we have the right values for the child column onchange trigger
async: false,
webURL: opt.relationshipWebURL,
listName: opt.relationshipList,
// Filter based on the currently selected parent column's value
CAMLQuery: camlQuery,
// Only get the parent and child columns
CAMLViewFields: "",
// Override the default view rowlimit and get all appropriate rows
CAMLRowLimit: 0,
// Even though setting IncludeMandatoryColumns to FALSE doesn't work as the docs describe, it fixes a bug in GetListItems with mandatory multi-selects
CAMLQueryOptions: opt.CAMLQueryOptions,
completefunc: function (xData) {
// Handle errors
$(xData.responseXML).find("errorstring").each(function () {
var thisFunction = "SPServices.SPCascadeDropdowns";
var errorText = $(this).text();
if (opt.debug && errorText === "One or more field types are not installed properly. Go to the list settings page to delete these fields.") {
errBox(thisFunction,
"relationshipListParentColumn: " + opt.relationshipListParentColumn + " or " +
"relationshipListChildColumn: " + opt.relationshipListChildColumn,
"Not found in relationshipList " + opt.relationshipList);
} else if (opt.debug && errorText === "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).") {
errBox(thisFunction,
"relationshipList: " + opt.relationshipList,
"List not found");
}
});
// Add an explanatory prompt
switch (childSelect.Type) {
case dropdownType.simple:
// Remove all of the existing options
$(childSelect.Obj).find("option").remove();
// If the column is required or the promptText option is empty, don't add the prompt text
if (!childColumnRequired && (opt.promptText.length > 0)) {
childSelect.Obj.append("");
} else if (!childColumnRequired) {
childSelect.Obj.append("");
}
break;
case dropdownType.complex:
// If the column is required, don't add the "(None)" option
choices = childColumnRequired ? "" : opt.noneText + "|0";
childSelect.Obj.val("");
break;
case dropdownType.multiSelect:
// Remove all of the existing options
$(childSelect.master.candidateControl).find("option").remove();
newMultiLookupPickerdata = "";
break;
default:
break;
}
// Get the count of items returned and save it so that we can select if it's a single option
// The item count is stored thus:
numChildOptions = parseFloat($(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount"));
// Add an option for each child item
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var thisOption = {};
// If relationshipListChildColumn is a Lookup column, then the ID should be for the Lookup value,
// else the ID of the relationshipList item
var thisValue = $(this).attr("ows_" + opt.relationshipListChildColumn);
if (typeof thisValue !== "undefined" && thisValue.indexOf(spDelim) > 0) {
thisOption = new SplitIndex(thisValue);
} else {
thisOption.id = $(this).attr("ows_ID");
thisOption.value = thisValue;
}
// If the relationshipListChildColumn is a calculated column, then the value isn't preceded by the ID,
// but by the datatype. In this case, thisOption.id should be the ID of the relationshipList item.
// e.g., float;#12345.67
if (isNaN(thisOption.id)) {
thisOption.id = $(this).attr("ows_ID");
}
// Save the id and value for the first child option in case we need to select it (selectSingleOption option is true)
firstChildOptionId = thisOption.id;
firstChildOptionValue = thisOption.value;
switch (childSelect.Type) {
case dropdownType.simple:
var selected = ($(this).attr("ows_ID") === childSelectSelected[0]) ? " selected='selected'" : "";
childSelect.Obj.append("");
break;
case dropdownType.complex:
if (thisOption.id === childSelectSelected[0]) {
childSelect.Obj.val(thisOption.value);
}
choices = choices + ((choices.length > 0) ? "|" : "") + thisOption.value + "|" + thisOption.id;
break;
case dropdownType.multiSelect:
$(childSelect.master.candidateControl).append("");
newMultiLookupPickerdata += thisOption.id + "|t" + thisOption.value + "|t |t |t";
break;
default:
break;
}
});
switch (childSelect.Type) {
case dropdownType.simple:
childSelect.Obj.trigger("change");
// If there is only one option and the selectSingleOption option is true, then select it
if (numChildOptions === 1 && opt.selectSingleOption === true) {
$(childSelect.Obj).find("option[value!='0']:first").attr("selected", "selected");
}
break;
case dropdownType.complex:
// Set the allowable choices
childSelect.Obj.attr("choices", choices);
// If there is only one option and the selectSingleOption option is true, then select it
if (numChildOptions === 1 && opt.selectSingleOption === true) {
// Set the input element value
$(childSelect.Obj).val(firstChildOptionValue);
// Set the value of the optHid input element
childSelect.optHid.val(firstChildOptionId);
}
// If there's no selection, then remove the value in the associated hidden input element (optHid)
if (childSelect.Obj.val() === "") {
childSelect.optHid.val("");
}
break;
case dropdownType.multiSelect:
// Clear the master
childSelect.master.data = "";
childSelect.MultiLookupPickerdata.val(newMultiLookupPickerdata);
// Clear any prior selections that are no longer valid or aren't selected
$(childSelect.master.resultControl).find("option").each(function () {
var thisSelected = $(this);
thisSelected.prop("selected", true);
$(childSelect.master.candidateControl).find("option[value='" + thisSelected.val() + "']").each(function () {
thisSelected.prop("selected", false);
});
});
GipRemoveSelectedItems(childSelect.master);
// Hide any options in the candidate list which are already selected
$(childSelect.master.candidateControl).find("option").each(function () {
var thisSelected = $(this);
$(childSelect.master.resultControl).find("option[value='" + thisSelected.val() + "']").each(function () {
thisSelected.remove();
});
});
GipAddSelectedItems(childSelect.master);
// Set master.data to the newly allowable values
childSelect.master.data = GipGetGroupData(newMultiLookupPickerdata);
// Trigger a dblclick so that the child will be cascaded if it is a multiselect.
$(childSelect.master.candidateControl).trigger("dblclick");
break;
default:
break;
}
}
});
// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
opt.completefunc();
}
}); // $(childColumns).each(function()
} // End cascadeDropdown
// function to convert complex dropdowns to simple dropdowns
$.fn.SPServices.SPComplexToSimpleDropdown = function (options) {
var opt = $.extend({}, {
listName: $().SPServices.SPListNameFromUrl(), // The list the form is working with. This is useful if the form is not in the list context.
columnName: "", // The display name of the column in the form
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options);
// Find the column's select (dropdown)
var columnSelect = $().SPServices.SPDropdownCtl({
displayName: opt.columnName
});
if (columnSelect.Obj.html() === null && opt.debug) {
errBox("SPServices.SPComplexToSimpleDropdown", "columnName: " + opt.columnName, TXTColumnNotFound);
return;
}
// If we don't have a complex dropdown, then there is nothing to do
if (columnSelect.Type !== dropdownType.complex) {
return;
}
// The available options are stored in the choices attribute of the complex dropdown's input element...
var choices = $(columnSelect.Obj).attr("choices").split("|");
// We need to know which option is selected already, if any
var complexSelectSelectedId = columnSelect.optHid.val();
// Build up the simple dropdown, giving it an easy to select id
var simpleSelectId = genContainerId("SPComplexToSimpleDropdown", columnSelect.Obj.attr("title"), opt.listName);
var simpleSelect = "";
// Append the new simple select to the form
columnSelect.Obj.closest("td").prepend(simpleSelect);
var simpleSelectObj = $("#" + simpleSelectId);
// Remove the complex dropdown functionality since we don't need it anymore...
columnSelect.Obj.closest("span").find("img").remove();
// ...and hide the input element
columnSelect.Obj.closest("span").find("input").hide();
// When the simple select changes...
simpleSelectObj.change(function () {
var thisVal = $(this).val();
// ...set the optHid input element's value to the valus of the selected option...
columnSelect.optHid.val(thisVal);
// ...and save the selected value as the hidden input's value only if the value is not equal to "0" (None)
$(columnSelect.Obj).val($(this).find("option[value='" + (thisVal !== "0" ? thisVal : "") + "']").html());
});
// Trigger a change to ensure that the selected value registers in the complex dropdown
simpleSelectObj.trigger("change");
// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
opt.completefunc();
}
}; // End $.fn.SPServices.SPConvertToSimpleDropdown
// Function to display related information when an option is selected on a form.
$.fn.SPServices.SPDisplayRelatedInfo = function (options) {
var opt = $.extend({}, {
listName: $().SPServices.SPListNameFromUrl(), // The list the form is working with. This is useful if the form is not in the list context.
columnName: "", // The display name of the column in the form
relatedWebURL: "", // [Optional] The name of the Web (site) which contains the related list
relatedList: "", // The name of the list which contains the additional information
relatedListColumn: "", // The internal name of the related column in the related list
relatedColumns: [], // An array of related columns to display
displayFormat: "table", // The format to use in displaying the related information. Possible values are: [table, list]
headerCSSClass: "ms-vh2", // CSS class for the table headers
rowCSSClass: "ms-vb", // CSS class for the table rows
CAMLQuery: "", // [Optional] For power users, this CAML fragment will be ed with the default query on the relatedList
numChars: 0, // If used on an input column (not a dropdown), no matching will occur until at least this number of characters has been entered
matchType: "Eq", // If used on an input column (not a dropdown), type of match. Can be any valid CAML comparison operator, most often "Eq" or "BeginsWith"
matchOnId: false, // By default, we match on the lookup's text value. If matchOnId is true, we'll match on the lookup id instead.
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options);
var divId;
var relatedColumnsXML = [];
var relatedListXML;
var thisFunction = "SPServices.SPDisplayRelatedInfo";
// Find the column's select (dropdown)
var columnSelect = $().SPServices.SPDropdownCtl({
displayName: opt.columnName
});
if (columnSelect.Obj.html() === null && opt.debug) {
errBox(thisFunction, "columnName: " + opt.columnName, TXTColumnNotFound);
return;
}
// Generate a unique id for the container
divId = genContainerId("SPDisplayRelatedInfo", opt.columnName, opt.listName);
// Get information about the related list and its columns
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
webURL: opt.relatedWebURL,
listName: opt.relatedList,
completefunc: function (xData) {
// If debug is on, notify about an error
$(xData.responseXML).find("faultcode").each(function () {
if (opt.debug) {
errBox(thisFunction, "relatedList: " + opt.relatedList, "List not found");
}
});
// Get info about the related list
relatedListXML = $(xData.responseXML).find("List");
// Save the information about each column requested
for (i = 0; i < opt.relatedColumns.length; i++) {
relatedColumnsXML[opt.relatedColumns[i]] = $(xData.responseXML).find("Fields > Field[Name='" + opt.relatedColumns[i] + "']");
}
relatedColumnsXML[opt.relatedListColumn] = $(xData.responseXML).find("Fields > Field[Name='" + opt.relatedListColumn + "']");
}
});
switch (columnSelect.Type) {
// Plain old select
case dropdownType.simple:
columnSelect.Obj.bind("change", function () {
showRelated(opt, divId, relatedListXML, relatedColumnsXML);
});
break;
// Input / Select hybrid
case dropdownType.complex:
// Bind to any change on the hidden input element
columnSelect.optHid.bind("propertychange", function () {
showRelated(opt, divId, relatedListXML, relatedColumnsXML);
});
break;
// Multi-select hybrid
case dropdownType.multiSelect:
if (opt.debug) {
errBox(thisFunction, "columnName: " + opt.columnName, "Multi-select columns not supported by this function");
}
break;
default:
break;
}
// Fire the change to set the initially allowable values
showRelated(opt, divId, relatedListXML, relatedColumnsXML);
}; // End $.fn.SPServices.SPDisplayRelatedInfo
function showRelated(opt, divId, relatedListXML, relatedColumnsXML) {
var columnSelectSelected;
var thisFunction = "SPServices.SPDisplayRelatedInfo";
// Find the column's select (dropdown)
var columnSelect = $().SPServices.SPDropdownCtl({
displayName: opt.columnName
});
// Get the current column selection(s)
columnSelectSelected = getDropdownSelected(columnSelect, opt.matchOnId);
if (columnSelect.Type === dropdownType.complex && opt.numChars > 0 && columnSelectSelected[0].length < opt.numChars) {
return;
}
// If the selection hasn't changed, then there's nothing to do right now. This is useful to reduce
// the number of Web Service calls when the parentSelect.Type = dropdownType.complex, as there are multiple propertychanges
// which don't require any action.
if (columnSelect.Obj.attr("showRelatedSelected") === columnSelectSelected[0]) {
return;
}
columnSelect.Obj.attr("showRelatedSelected", columnSelectSelected[0]);
// Remove the old container...
$("#" + divId).remove();
// ...and append a new, empty one
columnSelect.Obj.parent().append("");
// Get the list items which match the current selection
var camlQuery = "";
if (opt.CAMLQuery.length > 0) {
camlQuery += "";
}
// Need to handle Lookup columns differently than static columns
var relatedListColumnType = relatedColumnsXML[opt.relatedListColumn].attr("Type");
if (relatedListColumnType === "Lookup") {
camlQuery += "" : "'/>") +
escapeColumnValue(columnSelectSelected[0]) + "";
} else {
camlQuery += "" : opt.relatedListColumn + "'/>") +
escapeColumnValue(columnSelectSelected[0]) + "";
}
if (opt.CAMLQuery.length > 0) {
camlQuery += opt.CAMLQuery + "";
}
camlQuery += "";
var viewFields = " ";
for (i = 0; i < opt.relatedColumns.length; i++) {
viewFields += "";
}
$().SPServices({
operation: "GetListItems",
async: false,
webURL: opt.relatedWebURL,
listName: opt.relatedList,
// Filter based on the column's currently selected value
CAMLQuery: camlQuery,
CAMLViewFields: "" + viewFields + "",
// Override the default view rowlimit and get all appropriate rows
CAMLRowLimit: 0,
completefunc: function (xData) {
// Handle errors
$(xData.responseXML).find("errorstring").each(function () {
var errorText = $(this).text();
if (opt.debug && errorText === "One or more field types are not installed properly. Go to the list settings page to delete these fields.") {
errBox(thisFunction,
"relatedListColumn: " + opt.relatedListColumn,
"Column not found in relatedList " + opt.relatedList);
} else if (opt.debug && errorText === "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).") {
errBox(thisFunction,
"relatedList: " + opt.relatedList,
"List not found");
}
});
var outString;
// Output each row
switch (opt.displayFormat) {
// Only implementing the table format in the first iteration (v0.2.9)
case "table":
outString = "
";
outString += "
";
for (i = 0; i < opt.relatedColumns.length; i++) {
if (typeof relatedColumnsXML[opt.relatedColumns[i]] === "undefined" && opt.debug) {
errBox(thisFunction, "columnName: " + opt.relatedColumns[i], "Column not found in relatedList");
return;
}
outString += "
";
break;
default:
break;
}
// Write out the results
$("#" + divId).html(outString);
}
});
// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
opt.completefunc();
}
} // End showRelated
// Function to filter a lookup based dropdown
$.fn.SPServices.SPFilterDropdown = function (options) {
var opt = $.extend({}, {
relationshipWebURL: "", // [Optional] The name of the Web (site) which contains the relationshipList
relationshipList: "", // The name of the list which contains the lookup values
relationshipListColumn: "", // The internal name of the column in the relationship list
relationshipListSortColumn: "", // [Optional] If specified, sort the options in the dropdown by this column,
// otherwise the options are sorted by relationshipListColumn
relationshipListSortAscending: true, // [Optional] By default, the sort is ascending. If false, descending
columnName: "", // The display name of the column in the form
listName: $().SPServices.SPListNameFromUrl(), // The list the form is working with. This is useful if the form is not in the list context.
promptText: "", // [DEPRECATED] Text to use as prompt. If included, {0} will be replaced with the value of columnName. IOrignal value "Choose {0}..."
noneText: "(None)", // [Optional] Text to use for the (None) selection. Provided for non-English language support.
CAMLQuery: "", // This CAML fragment will be applied to the relationshipList
CAMLQueryOptions: "FALSE", // Need this to mirror SharePoint's behavior, but it can be overridden
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages; if false, run silent
}, options);
var choices = "";
var columnSelectSelected = null;
var newMultiLookupPickerdata;
var columnColumnRequired;
var thisFunction = "SPServices.SPFilterDropdown";
// Find the column's select (dropdown)
var columnSelect = $().SPServices.SPDropdownCtl({
displayName: opt.columnName
});
if (columnSelect.Obj.html() === null && opt.debug) {
errBox(thisFunction, "columnName: " + opt.columnName, TXTColumnNotFound);
return;
}
// Get the current column selection(s)
columnSelectSelected = getDropdownSelected(columnSelect, true);
// Get the relationshipList items which match the current selection
var sortColumn = (opt.relationshipListSortColumn.length > 0) ? opt.relationshipListSortColumn : opt.relationshipListColumn;
var sortOrder = (opt.relationshipListSortAscending === true) ? "" : "Ascending='FALSE'";
var camlQuery = "";
if (opt.CAMLQuery.length > 0) {
camlQuery += opt.CAMLQuery;
}
camlQuery += "";
// Get information about columnName from the current list
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
listName: opt.listName,
completefunc: function (xData) {
$(xData.responseXML).find("Fields").each(function () {
$(this).find("Field[DisplayName='" + opt.columnName + "']").each(function () {
// Determine whether columnName is Required
columnColumnRequired = ($(this).attr("Required") === "TRUE");
// Stop looking; we're done
return false;
});
});
}
});
$().SPServices({
operation: "GetListItems",
// Force sync so that we have the right values for the column onchange trigger
async: false,
webURL: opt.relationshipWebURL,
listName: opt.relationshipList,
// Filter based on the specified CAML
CAMLQuery: camlQuery,
// Only get the columnName's data (plus columns we can't prevent)
CAMLViewFields: "",
// Override the default view rowlimit and get all appropriate rows
CAMLRowLimit: 0,
// Even though setting IncludeMandatoryColumns to FALSE doesn't work as the docs describe, it fixes a bug in GetListItems with mandatory multi-selects
CAMLQueryOptions: opt.CAMLQueryOptions,
completefunc: function (xData) {
// Handle errors
$(xData.responseXML).find("errorstring").each(function () {
var errorText = $(this).text();
if (opt.debug && errorText === "One or more field types are not installed properly. Go to the list settings page to delete these fields.") {
errBox(thisFunction,
"relationshipListColumn: " + opt.relationshipListColumn,
"Not found in relationshipList " + opt.relationshipList);
} else if (opt.debug && errorText === "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).") {
errBox(thisFunction,
"relationshipList: " + opt.relationshipList,
"List not found");
}
});
// Add an explanatory prompt
switch (columnSelect.Type) {
case dropdownType.simple:
// Remove all of the existing options
$(columnSelect.Obj).find("option").remove();
// If the column is required or the promptText option is empty, don't add the prompt text
if (!columnColumnRequired && (opt.promptText.length > 0)) {
columnSelect.Obj.append("");
} else if (!columnColumnRequired) {
columnSelect.Obj.append("");
}
break;
case dropdownType.complex:
// If the column is required, don't add the "(None)" option
choices = columnColumnRequired ? "" : opt.noneText + "|0";
columnSelect.Obj.val("");
break;
case dropdownType.multiSelect:
// Remove all of the existing options
$(columnSelect.master.candidateControl).find("option").remove();
newMultiLookupPickerdata = "";
break;
default:
break;
}
// Add an option for each item
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var thisOption = {};
// If relationshipListColumn is a Lookup column, then the ID should be for the Lookup value,
// else the ID of the relationshipList item
var thisValue = $(this).attr("ows_" + opt.relationshipListColumn);
if (typeof thisValue !== "undefined" && thisValue.indexOf(spDelim) > 0) {
thisOption = new SplitIndex(thisValue);
} else {
thisOption.id = $(this).attr("ows_ID");
thisOption.value = thisValue;
}
// If the relationshipListColumn is a calculated column, then the value isn't preceded by the ID,
// but by the datatype. In this case, thisOption.id should be the ID of the relationshipList item.
// e.g., float;#12345.67
if (isNaN(thisOption.id)) {
thisOption.id = $(this).attr("ows_ID");
}
switch (columnSelect.Type) {
case dropdownType.simple:
var selected = ($(this).attr("ows_ID") === columnSelectSelected[0]) ? " selected='selected'" : "";
columnSelect.Obj.append("");
break;
case dropdownType.complex:
if (thisOption.id === columnSelectSelected[0]) {
columnSelect.Obj.val(thisOption.value);
}
choices = choices + ((choices.length > 0) ? "|" : "") + thisOption.value + "|" + thisOption.id;
break;
case dropdownType.multiSelect:
$(columnSelect.master.candidateControl).append("");
newMultiLookupPickerdata += thisOption.id + "|t" + thisOption.value + "|t |t |t";
break;
default:
break;
}
});
switch (columnSelect.Type) {
case dropdownType.simple:
columnSelect.Obj.trigger("change");
break;
case dropdownType.complex:
columnSelect.Obj.attr("choices", choices);
columnSelect.Obj.trigger("propertychange");
break;
case dropdownType.multiSelect:
// Clear the master
columnSelect.master.data = "";
columnSelect.MultiLookupPickerdata.val(newMultiLookupPickerdata);
// Clear any prior selections that are no longer valid
$(columnSelect.master.resultControl).find("option").each(function () {
var thisSelected = $(this);
$(this).attr("selected", "selected");
$(columnSelect.master.candidateControl).find("option").each(function () {
if ($(this).html() === thisSelected.html()) {
thisSelected.removeAttr("selected");
}
});
});
GipRemoveSelectedItems(columnSelect.master);
// Hide any options in the candidate list which are already selected
$(columnSelect.master.candidateControl).find("option").each(function () {
var thisSelected = $(this);
$(columnSelect.master.resultControl).find("option").each(function () {
if ($(this).html() === thisSelected.html()) {
thisSelected.remove();
}
});
});
GipAddSelectedItems(columnSelect.master);
// Set master.data to the newly allowable values
columnSelect.master.data = GipGetGroupData(newMultiLookupPickerdata);
// Trigger a dblclick so that the child will be cascaded if it is a multiselect.
$(columnSelect.master.candidateControl).trigger("dblclick");
break;
default:
break;
}
}
});
// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
opt.completefunc();
}
}; // End $.fn.SPServices.SPFilterDropdown
// Utility function to show the results of a Web Service call formatted well in the browser.
$.fn.SPServices.SPDebugXMLHttpResult = function (options) {
var opt = $.extend({}, {
node: null, // An XMLHttpResult object from an ajax call
indent: 0 // Number of indents
}, options);
var i;
var NODE_TEXT = 3;
var NODE_CDATA_SECTION = 4;
var outString = "";
// For each new subnode, begin rendering a new TABLE
outString += "
";
// DisplayPatterns are a bit unique, so let's handle them differently
if (opt.node.nodeName === "DisplayPattern") {
outString += "
" + opt.node.nodeName +
"
";
// A node which has no children
} else if (!opt.node.hasChildNodes()) {
outString += "
";
}
// A CDATA_SECTION node
} else if (opt.node.hasChildNodes() && opt.node.firstChild.nodeType === NODE_CDATA_SECTION) {
outString += "
" + opt.node.nodeName +
"
";
// A TEXT node
} else if (opt.node.hasChildNodes() && opt.node.firstChild.nodeType === NODE_TEXT) {
outString += "
" + opt.node.nodeName +
"
" + checkLink(opt.node.firstChild.nodeValue) + "
";
// Handle child nodes
} else {
outString += "
" + opt.node.nodeName + "
";
if (opt.node.attributes) {
outString += "
" + showAttrs(opt.node) + "
";
}
// Since the node has child nodes, recurse
outString += "
";
for (i = 0; i < opt.node.childNodes.length; i++) {
outString += $().SPServices.SPDebugXMLHttpResult({
node: opt.node.childNodes.item(i),
indent: opt.indent + 1
});
}
outString += "
";
}
outString += "
";
// Return the HTML which we have built up
return outString;
}; // End $.fn.SPServices.SPDebugXMLHttpResult
// Function which returns the account name for the current user in DOMAIN\username format
$.fn.SPServices.SPGetCurrentUser = function (options) {
var opt = $.extend({}, {
webURL: "", // URL of the target Site Collection. If not specified, the current Web is used.
fieldName: "Name", // Specifies which field to return from the userdisp.aspx page
fieldNames: {}, // Specifies which fields to return from the userdisp.aspx page - added in v0.7.2 to allow multiple columns
debug: false // If true, show error messages; if false, run silent
}, options);
// The current user's ID is reliably available in an existing JavaScript variable
if (opt.fieldName === "ID" && typeof currentContext.thisUserId !== "undefined") {
return currentContext.thisUserId;
}
var thisField = "";
var theseFields = {};
var fieldCount = opt.fieldNames.length > 0 ? opt.fieldNames.length : 1;
var thisUserDisp;
var thisWeb = opt.webURL.length > 0 ? opt.webURL : $().SPServices.SPGetCurrentSite();
// Get the UserDisp.aspx page using AJAX
$.ajax({
// Need this to be synchronous so we're assured of a valid value
async: false,
// Force parameter forces redirection to a page that displays the information as stored in the UserInfo table rather than My Site.
// Adding the extra Query String parameter with the current date/time forces the server to view this as a new request.
url: ((thisWeb === "/") ? "" : thisWeb) + "/_layouts/userdisp.aspx?Force=True&" + new Date().getTime(),
complete: function (xData) {
thisUserDisp = xData;
}
});
for (i = 0; i < fieldCount; i++) {
// The current user's ID is reliably available in an existing JavaScript variable
if (opt.fieldNames[i] === "ID") {
thisField = currentContext.thisUserId;
} else {
var thisTextValue;
if (fieldCount > 1) {
thisTextValue = RegExp("FieldInternalName=\"" + opt.fieldNames[i] + "\"", "gi");
} else {
thisTextValue = RegExp("FieldInternalName=\"" + opt.fieldName + "\"", "gi");
}
$(thisUserDisp.responseText).find("table.ms-formtable td[id^='SPField']").each(function () {
if (thisTextValue.test($(this).html())) {
// Each fieldtype contains a different data type, as indicated by the id
switch ($(this).attr("id")) {
case "SPFieldText":
thisField = $(this).text();
break;
case "SPFieldNote":
thisField = $(this).find("div").html();
break;
case "SPFieldURL":
thisField = $(this).find("img").attr("src");
break;
// Just in case
default:
thisField = $(this).text();
break;
}
// Stop looking; we're done
return false;
}
});
}
if (opt.fieldNames[i] !== "ID") {
thisField = (typeof thisField !== "undefined") ? thisField.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '') : null;
}
if (fieldCount > 1) {
theseFields[opt.fieldNames[i]] = thisField;
}
}
return (fieldCount > 1) ? theseFields : thisField;
}; // End $.fn.SPServices.SPGetCurrentUser
// Function which provides a link on a Lookup column for the user to follow
// which allows them to add a new value to the Lookup list.
// Based on http://blog.mastykarz.nl/extending-lookup-fields-add-new-item-option/
// by Waldek Mastykarz
$.fn.SPServices.SPLookupAddNew = function (options) {
var opt = $.extend({}, {
lookupColumn: "", // The display name of the Lookup column
promptText: "Add new {0}", // Text to use as prompt + column name
newWindow: false, // If true, the link will open in a new window *without* passing the Source.
ContentTypeID: "", // [Optional] Pass the ContentTypeID if you'd like to specify it
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options);
var thisFunction = "SPServices.SPLookupAddNew";
// Find the lookup column's select (dropdown)
var lookupSelect = $().SPServices.SPDropdownCtl({
displayName: opt.lookupColumn
});
if (lookupSelect.Obj.html() === null && opt.debug) {
errBox(thisFunction, "lookupColumn: " + opt.lookupColumn, TXTColumnNotFound);
return;
}
var newUrl = "";
var lookupListUrl = "";
var lookupColumnStaticName = "";
// Use GetList for the current list to determine the details for the Lookup column
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
listName: $().SPServices.SPListNameFromUrl(),
completefunc: function (xData) {
$(xData.responseXML).find("Field[DisplayName='" + opt.lookupColumn + "']").each(function () {
lookupColumnStaticName = $(this).attr("StaticName");
// Use GetList for the Lookup column's list to determine the list's URL
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
listName: $(this).attr("List"),
completefunc: function (xData) {
$(xData.responseXML).find("List").each(function () {
lookupListUrl = $(this).attr("WebFullUrl");
// Need to handle when list is in the root site
lookupListUrl = lookupListUrl !== SLASH ? lookupListUrl + SLASH : lookupListUrl;
});
}
});
// Get the NewItem form for the Lookup column's list
newUrl = getListFormUrl($(this).attr("List"), "NewForm");
// Stop looking;we're done
return false;
});
}
});
if (lookupListUrl.length === 0 && opt.debug) {
errBox(thisFunction, "lookupColumn: " + opt.lookupColumn, "This column does not appear to be a lookup column");
return;
}
if (newUrl.length > 0) {
// Build the link to the Lookup column's list enclosed in a div with the id="SPLookupAddNew_" + lookupColumnStaticName
var newHref = lookupListUrl + newUrl;
// If requested, open the link in a new window and if requested, pass the ContentTypeID
newHref += opt.newWindow ?
((opt.ContentTypeID.length > 0) ? "?ContentTypeID=" + opt.ContentTypeID : "") + "' target='_blank'" :
"?" + ((opt.ContentTypeID.length > 0) ? "ContentTypeID=" + opt.ContentTypeID + "&" : "") + "Source=" + escapeUrl(location.href) + "'";
var newLink = "
");
// Apply the CSS class to the headers
var scriptAuditContainer = $("#SPScriptAudit");
scriptAuditContainer.find("th").attr("class", "ms-vh2-nofilter");
// Don't bother with the lists if the options don't require them
if (opt.auditForms || opt.auditViews) {
// First, get all of the lists within the site
$().SPServices({
operation: "GetListCollection",
webURL: opt.webURL,
async: false, // Need this to be synchronous so we're assured of a valid value
completefunc: function (xData) {
$(xData.responseXML).find("List").each(function () {
listXml = $(this);
// If listName has been specified, then only return results for that list
if ((opt.listName.length === 0) || (listXml.attr("Title") === opt.listName)) {
// Don't work with hidden lists unless we're asked to
if ((opt.showHiddenLists && listXml.attr("Hidden") === "False") || !opt.showHiddenLists) {
// Audit the list's forms
if (opt.auditForms) {
// Get the list's Content Types, therefore the form pages
$().SPServices({
operation: "GetListContentTypes",
webURL: opt.webURL,
listName: listXml.attr("ID"),
async: false, // Need this to be synchronous so we're assured of a valid value
completefunc: function (xData) {
$(xData.responseXML).find("ContentType").each(function () {
// Don't deal with folders
if ($(this).attr("ID").substring(0, 6) !== "0x0120") {
var formUrls = $(this).find("FormUrls");
for (i = 0; i < formTypes.length; i++) {
// Look for a customized form...
$(formUrls).find(formTypes[i][0]).each(function () {
SPScriptAuditPage(opt, listXml, "Form", this.nodeName, ((opt.webURL.length > 0) ? opt.webURL : $().SPServices.SPGetCurrentSite()) + SLASH + $(this).text());
formTypes[i][2] = true;
});
// ...else the uncustomized form
if (!formTypes[i][2]) {
var defaultViewUrl = listXml.attr("DefaultViewUrl");
SPScriptAuditPage(opt, listXml, "Form", formTypes[i][0],
defaultViewUrl.substring(0, defaultViewUrl.lastIndexOf(SLASH) + 1) + formTypes[i][1]);
}
}
// Reset the form types
for (i = 0; i < formTypes.length; i++) {
formTypes[i][2] = false;
}
}
});
}
});
}
// Audit the list's views
if (opt.auditViews) {
// Get the list's Views
$().SPServices({
operation: "GetViewCollection",
webURL: opt.webURL,
listName: listXml.attr("ID"),
async: false, // Need this to be synchronous so we're assured of a valid value
completefunc: function (xData) {
$(xData.responseXML).find("View").each(function () {
SPScriptAuditPage(opt, listXml, "View", $(this).attr("DisplayName"), $(this).attr("Url"));
});
}
});
}
}
}
});
}
});
}
// Don't bother with auditing pages if the options don't require it
var numLists = 0;
var listsArray = [];
if (typeof opt.auditPagesListName === "string") {
numLists = 1;
listsArray.push(opt.auditPagesListName);
} else {
numLists = opt.auditPagesListName.length;
listsArray = opt.auditPagesListName;
}
if (opt.auditPages) {
for (i = 0; i < numLists; i++) {
$().SPServices({
operation: "GetList",
async: false,
cacheXML: true,
webURL: opt.webURL,
listName: listsArray[i],
completefunc: function (xData) {
$(xData.responseXML).find("List").each(function () {
listXml = $(this);
});
}
});
// Get all of the items from the Document Library
$().SPServices({
operation: "GetListItems",
async: false,
webURL: opt.webURL,
listName: listsArray[i],
CAMLQuery: "Folder",
CAMLViewFields: "",
CAMLRowLimit: 0,
completefunc: function (xData) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var thisPageUrl = $(this).attr("ows_FileRef").split(spDelim)[1];
var thisTitle = $(this).attr("ows_Title");
var thisPageType = (typeof thisTitle !== "undefined") ? thisTitle : "";
if (thisPageUrl.indexOf(".aspx") > 0) {
SPScriptAuditPage(opt, listXml, "Page", thisPageType, SLASH + thisPageUrl);
}
});
}
});
}
}
// Remove progress indicator and make the output pretty by cleaning up the ms-alternating CSS class
scriptAuditContainer.find("tr[class='ms-alternating']:even").removeAttr("class");
}; // End $.fn.SPServices.SPScriptAudit
// Displays the usage of scripts in a site
function SPScriptAuditPage(opt, listXml, pageClass, pageType, pageUrl) {
var i = 0;
var jQueryPage = 0;
var pageScriptSrc = {};
pageScriptSrc.type = [];
pageScriptSrc.src = [];
pageScriptSrc.script = [];
var scriptRegex = RegExp("