Giter Club home page Giter Club logo

sympmarc / spservices Goto Github PK

View Code? Open in Web Editor NEW
208.0 208.0 62.0 6.54 MB

SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.

License: MIT License

JavaScript 95.91% HTML 1.72% CSS 0.08% ASP.NET 2.22% Less 0.08%
javascript sharepoint soap spservices

spservices's Introduction

SPServices

Code Climate CDNJS

SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.

SPServices is primarily hosted on Codeplex, with this repository mirroring most of the downloads there.

This is a work in progress. It's a port of SPServices from Codeplex to GitHub, with a rewrite along the way.

Until otherwise announced, this is not a fully functional version of SPServices. When complete, this version will be:

  • SPServices 2.0
  • AMD-enabled using RequireJS
  • Converted from a monolithic file to modules
  • Enabled to take advantage of SharePoint's REST APIs - where available - for internal calls to get list data in the value-added functions

Progress Report

  • 2016-10-12 Great new home page for SPServices, thanks to @joshmcrty
  • 2016-07-10 All modules are in place, most documentation has been migrated over, and building is functional (if simplistic)
  • 2015-12-06 Began adding modules back in to build up a "full build" of existing SPService functionality.
  • 2015-12-05 Initial tests using QUnit are in place. Instructions below.
  • 2015-12-01 The monolithic SPServices file is not broken out into modules, one per major function.
  • 2016-01-04 SPServices 2.0 is now building and operational - pre-alpha.
  • 2016-03-07 Switched from grunt/requirejs to gulp/webpack.

For full documentation, please visit http://spservices.codeplex.com/documentation

Contribute

Would you like to contribute to the next generation of SPServices?

  • Test the "pre-alpha" builds of SPServices 2.0. If you're familiar enough with the library to drop builds into your test environments, that would be a great help. I've tested using the same lists and pages I always use, but more real-world testing would be good. Report any issues you find using GitHub issues.
  • Write some tests. I've started writing tests with QUnit, but I've only scratched the surface. Writing good tests here is difficult, as we have to be sitting on top of SharePoint; in greenfield development, we can test anywhere. You'll find some instructions for how to use the existing tests on the GitHub pages.
  • Migrate the documentation from Codeplex to GitHub - Since Codeplex is falling apart, there's no reason to leave the documentation there, either. There are a few dozen pages (I can't actually count the pages on Codeplex easily) of documentation, and it's probably easiest just to move the over to GitHub manually.
  • Move the discussions off Codeplex - This one is hardest, I think. IMO, one of the big values to SPServices is the historical discussions about how to use it. But those discussions have covered many other things as well, and I'd hate to lose any of it. I'm not sure how to go about this, so if anyone has some experience moving forums like this, I'm all ears.
  • Propose improvements - I ask the community for suggestions all the time, but I don't get a lot of them. If you've solved some gnarly SharePoint UI problem and would be willing to submit your code or just wish that someone would fix the darn _____, then let me know in the GitHub issues. Consider the issues our own UserVoice for SPServices.

Development

Prerequisites

  1. nodeJS
  2. gulp

Setup Environment

  1. Fork this repository and checkout the source

  2. From the root of the project, run:

    npm install
    

    This will install all of the necessary dependencies

Run a build

  1. run:

    gulp
    

    TODO: complete documentation here on what a build will actually do.

Develop and Watch

A gulp target called watch is available for linting code as files are changed and saved. To use it, simply run:

gulp watch

This will start a job that watches the sources files as they are saved and runs the linting tool to ensure they are clean of issues.

Unit Tests

Unit test cases are written under the test folder using QUnit. Tests will run in the dev.aspx above.

Currently the tests require a real SharePoint server. The tests will create and delete some test data to validate basic core calls.

Documentation

Documentation is generated using the files in the /docs directory of this repo. Pages are written in Markdown with YAML front matter and then converted to HTML for hosting on GitHub pages via the gh-pages branch. The gh-pages branch should never need to be directly edited or modified.

To edit documentation and see a live preview of changes in the browser, run:

gulp servedocs

This will build the documentation and serve the HTML files using Browsersync. Any changes to the source files in /docs will be reloaded in the browser automatically.

When documentation changes are complete:

  1. Stop the servedocs task (Ctrl+C or Cmd+C)

  2. Run gulp docs to clean the dist/docs folder and rebuild it using the latest source files from /docs

  3. If ready to deploy to gh-pages, run:

    gulp deploydocs
    

This will package everything in the /dist folder into a ZIP file, then update the gh-pages branch with the ZIP file and all documentation files. Changes may take a few minutes to show up on http://sympmarc.github.io/SPServices.

spservices's People

Contributors

aschulz01 avatar dimkk avatar jmgore75 avatar johnnliu avatar joshmcrty avatar juliemturner avatar laskewitz avatar lirichard avatar purtuga avatar scatcher avatar simkessy avatar spcfran avatar sympmarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spservices's Issues

SPFilterDropdown CAMLQuery issue

Hi,

I am working in SP-Online and tried to use the SPFilterDropdown function. The caml below seems to be OK as it is working in other tools. But for same reason it is not working with SPServices.

Environment:

  1. I have a Library called "Docs" with DocumentSets. I have added a Lookup field pointing to another List called "Processes"

2.) Within the List Processes I have created a LookUp field to "Docs" using the auto generated field "Related Process (Count Related)" and named it "RelatedDocSetCount".

The Dropdown should only show entries where the column "RelatedDocSetCount" is 0. So used the code below but now my dropdown is empty. Any ideas?

$().SPServices.SPFilterDropdown({ relationshipList: "Processes", relationshipListColumn: "Title", columnName: "RelatedProcess", CAMLQuery: "<Eq><FieldRef Name='RelatedDocSetCount'/><Value Type='Lookup'>0</Value></Eq>", completefunc: null, debug: true });

$().SPServices.SPArrangeChoices saving not working in SP2013

I have bunch of radio buttons groups and showing the horizontally with ().SPServices.SPArrangeChoices. all radio buttons showing correct. but saving not working for them. If I remove this code everything work fine. I need to show horizantal and save data.

<script language="javascript" type="text/javascript" src="/dept/it/SiteAssets/jquery.min.js">//version jQuery v1.11.1 </script> //
<script language="javascript" type="text/javascript" src="/dept/it/SiteAssets/jquery.SPServices-0.5.8.js">// tried with SPServices 2014.02,SPServices 2014.01
</script> 

ChoiceArrange("Did the project implementation go as planned");
    ChoiceArrange("Did project communications meet business needs");
    ChoiceArrange("Was the project managed professionally");
    ChoiceArrange("Were the roles on the project clearly defined");

function ChoiceArrange(columnName){
$().SPServices.SPArrangeChoices({               
            columnName:columnName ,
            perRow: 5
    });

it is Sharepoint 2013

GetToDosForItem works only for first task in workflow

Hi,

On SP 2010 at least, GetToDosForItem works but only for the first task in a workflow.

On the 2nd task, we get this error:

soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.'ows_FormData' is a duplicate attribute name. Line 3, position 1984.

I'm using the code example from the doc.

Thanks!

Can SPCascadedDropdowns have two parents

Hi

Firstly, SPServices has been a real lifesaver when compared with having to write acres of plumbing code
in say SPFx +Office Fabric + ReactJS when building a parent /relationships UI IMHO .

Anyway back to my question. I want to use a lookup which works against the relationship list as shown below. I want select my colour indicator based on the values held in Department and Company . Can I use CAML to argument the first Parent column?

Title Department Company
Green Sales Comp1
N/A Sales Comp2
Amber Sales Comp3

CAML query hides rich text fields?

When i console log my data from getting list data from a list without a query, all fields show up. When i add a query to my call, it hides any rich text fields i have?

HELP

Weburl

I am running SPServices' GetListItems from a subsite (https://something.sharepoint.com/sites/intranet/op1/) querying a document library in the root. This is my SPServices code.

$().SPServices(
{
    webUrl         : 'https://something.sharepoint.com/sites/intranet/',
    operation      : "GetListItems",
    async          : true,
    listName       : 'Documents',
    CAMLViewFields : "<ViewFields><FieldRef Name='Title' /><FieldRef Name='EncodedAbsUrl'/></ViewFields>",
    // CAMLQuery      : camlQuery,
    completefunc   : function (xData, Status)
        {
            console.log('doclib_getListItems [xData]', xData);
            console.log('doclib_getListItems [Status]', Status);
        }
});

However I am getting an error "POST https://something.sharepoint.com/sites/intranet/op1/_vti_bin/Lists.asmx 500 (Internal Server Error)". I think it is trying to find the "Documents" list in the subsite but not in the site indicated by the webUrl. Is there a way to force SPServices to query https://something.sharepoint.com/sites/intranet/_vti_bin/Lists.asmx ?

Please note the opt1 in the subsite url.

thanks!

Does SPServices cater for filling in fields from another list

Hi,

I am currently using SPCascadeDropdowns & SPDisplayRelatedInfo. Is there a way of having something similar to the SPDisplayRelatedInfo which automatically fills in the fields in the current Form from another list based on the selection of the dropdown please?

Typo: SPServices.core.js (line 609 - OFFICIALFILE Operations) - too many parameters

/src/core/SPServices.core.js (line 609) is passing 7 parameters
609 utils.addToPayload(opt, SOAPEnvelope, ["fileToSubmit"], ["properties"], ["recordRouting"], ["sourceUrl"], ["userName"]);

/src/core/SPServices.utils.js (line 216) requires 3 parameters, the 3rd being an array
216 addToPayload: function(opt, SOAPEnvelope, paramArray) {

package.json is missing webpack-stream

Hi all,
Just tried to build using gulp and got this error. Will submit a pull request to fix this, if all right with you guys?

Error: Cannot find module 'webpack-stream' at Function.Module._resolveFilename (module.js:339:15) at Function.Module._load (module.js:290:25) at Module.require (module.js:367:17) at require (internal/module.js:16:19) at Object.<anonymous> (C:\Users\bchan\Work\SPServices\Gulpfile.js:12:15) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17)

"siteRoot" initialized wrong in function "SPServiceContext"

If the SharePoint-address contains portnumbers (e.g. http://knlemosswebtest04:8081), the initialization of the variable "siteRoot" in the function "SPServicesContext" is done wrong:

var siteRoot = location.protocol + "//" + location.host + (location.port !== "" ? location.port : "");

location.host is already delivering the hostname + port. In this case the port will be addes twice:
spservice_1

The correct way should be: var siteRoot = location.protocol + "//" + location.host;

Get SPCascadeDropdowns Working with SharePoint 2013 Quick Edit View

I took the liberty to add this issue from codeplex as it was not only the first, but also the second highest voted issue there.

From [Get SPCascadeDropdowns Working with SharePoint 2013 Quick Edit View]_(http://spservices.codeplex.com/workitem/10181)
"SPCascadeDropdowns does not work with the "Quick Edit" view - aka the new Datasheet view - in SharePoint 2013 as of SPServices 2013.01."_

From SP Cascading Drop Downs in Quick Edit mode
"From https://spservices.codeplex.com/discussions/567707

Marc - Great stuff!

Is there a way to have the cascade feature work even when a user is editing their list in "Quick Edit" mode (datasheet entry in SP 2013)?
After I select my first column (parent), ALL the choices are still available in the second (child) column; no filtering has occurred. I know I placed the code on the New and Edit form...

Can this be done?
Thanks, Jean"

Grunt and grunt deploy building incomplete jquery.SPServices.js

Following the readme instructions to build (i.e. using grunt or grunt deploy), the output under /build appears truncated and is missing the functions (e.g., SPRequireUnique, etc.)

For comparison, jquery.SPServices.js in /dist is 4,575 lines while with a clean git clone /build creates one that is 2,965 lines. It looks like grunt is not traversing into /src/utils and /src/value-add to include those files.

Does Gruntfile.js or the readme need to be updated?

I'm building this on a fresh vagrant box built from https://atlas.hashicorp.com/lazygray/boxes/heroku-cedar-14

spservices.js.. Error:- Uncaught (in > promise) TypeError: Cannot read properties of undefined (reading > 'LookupList')

Inside our SPFx web part we have the following code inside the spservices.js code:-

spservices.prototype.getLookupFieldOptions = function (siteUrl, listId, fieldInternalName) {
return __awaiter(this, void 0, void 0, function () {
var fieldOptions, web, results, options, _i, options_1, option, error_14;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fieldOptions = [];
_a.label = 1;
case 1:
_a.trys.push([1, 5, , 6]);
web = new Web(siteUrl);
return [4 /yield/, web.lists.getById(listId)
.fields.usingCaching()
.filter("InternalName eq '" + fieldInternalName + "'")
.select("LookupList", "LookupWebId", "LookupField")
.top(1)
.get()];
case 2:
results = _a.sent();
if (!results) return [3 /break/, 4];
return [4 /yield/, web.lists.getById(results[0].LookupList)
.items.usingCaching()
.select("ID", results[0].LookupField)
.getAll()];
case 3:
options = _a.sent();
if (options && options.length > 0) {
for (_i = 0, options_1 = options; _i < options_1.length; _i++) {
option = options_1[_i];
fieldOptions.push({
key: option.ID,
text: option[results[0].LookupField]
});
}
}
_a.label = 4;
case 4: return [3 /break/, 6];
case 5:
error_14 = _a.sent();
return [2 /return/, Promise.reject(error_14)];
case 6: return [2 /return/, fieldOptions];
}
});
});
};

but on runtime the SPFx web part will return this error and it will keep loading forever:-

calendar-web-part_a87ac4ce95dc9057c9f00ccd9727c133.js:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'LookupList')

this is the piece of code which is returning the error:-

return [4 /*yield*/, web.lists.getById(results[0].LookupList)

as follow:-

image

any advice on this please?

SPServices.SPCascadeDropdown/SPFilterDropdown - Lookup multi value

Hello,

I was wondering if I'm missing something or if it isn't possible but I'm having a problem where I want to filter based on a multi value lookup. An example below.

So I've got a list Brands with just some titles like BrandA, BrandB, BrandC.
Then I've got a list with Machines that has a lookup to brands and 1 machine can support multiple brands.
Then I've got a 3rd list: Offers which points to a machine and a brand, but I want the Offers list to filter the Machines based on the supported brands. That way if MachineA only supports BrandA, I want to see only BrandA, if MachineC supports BrandA and BrandB then I want to choose BrandA or BrandB or BrandA and BrandB. But right now I can't filter multiple values, it would only show BrandA in the dropdown. Am I doing this wrong or is it not supported to filter based on a multi value lookup?

So it would like look:

Brands

BrandA
BrandB
BrandC

Machines - Brands (Lookup to Brands)

MachineA | BrandA
MachineB | BrandB
MachineC | BrandA,BrandB

Offers - Machine - Brands (Machine lookup to machines, Brands lookup to Brands)

Offer1 | MachineC | BrandA,BranddB


jQuery/SPServices:

$().SPServices.SPCascadeDropdowns({
relationshipList: "Machines",
relationshipListParentColumn: "Title",
relationshipListChildColumn: "Brands",
parentColumn: "Machine",
childColumn: "Brands",
debug: true
});

$().SPServices.SPFilterDropdown({
relationshipList: "Machines",
relationshipListColumn: "Brands",
columnName: "Brands",
CAMLQuery: "" + machineField.GetValue() + "",
debug: true
});

Many thanks & thank you for such an awesome addition which saves me many headaches!

is:issue is:open GetListItms show fine when using one list but data shows undefined on another.

Hello. I'm stumped on why my data is coming up undefined. Here's the scenario. I have Sharepoint online 2016 and I have some code written that stores objects to an array and I can use that data when I need to like clicking through with a button. I tested the code on the MicroFeed list that comes with Sharepoint upon installation and it works GREAT!!!. But when I simply change to another list and try to show 2 different fields the correct number of records come back bu the data is undefined.

Update: The issue was that I had to use the internal name of the List Column. The internal name is different than the Display name in some cases

Can this plugin work on a plain web app or does it require SP.js?

It appears this plugin is only for use on a page served up by SharePoint or a page with SharePoint JS libraries already available. In other words, is this plugin dependent upon the SP JavaScripts? I don't see that mentioned anywhere on the home page. Thanks!

Can SPCascadedropdowns be reset?

Once I have triggered a SPCascadedropdowns script, can I reset one of the lookup fields (remove filter, show all lookup values again) in case that the user triggers a certain event?

If yes, how?

Should check scriptSrc for undefined along with null here. Otherwise SPScriptAudit breaks down.

if (scriptSrc !== null && scriptSrc.length > 0 && !coreScript(scriptSrc)) {

The hyperlink referenced line checks scriptSrc variable to be not equal to null, but when it's undefined, it's not exactly null, and scriptSrc.length throws an Exception:

jquery.min.js:formatted:3981 Uncaught TypeError: Cannot read property 'length' of undefined
    at Object.success (jquery.SPServices-2014.02.js?_=1575556158629:3117)
    at j (jquery.min.js:formatted:1341)
    at Object.fireWith [as resolveWith] (jquery.min.js:formatted:1398)
    at x (jquery.min.js:formatted:4008)
    at b (jquery.min.js:formatted:4209)
    at Object.send (jquery.min.js:formatted:4212)
    at Function.ajax (jquery.min.js:formatted:3978)
    at SPScriptAuditPage (jquery.SPServices-2014.02.js?_=1575556158629:3104)
    at Element.<anonymous> (jquery.SPServices-2014.02.js?_=1575556158629:3081)
    at Function.each (jquery.min.js:formatted:167)

Encountered when calling

$().SPServices.SPScriptAudit({
auditForms:false, auditViews:false, outputId: "js-output", listName:'layout', showSrc:true
});

and a page such as PageNotFoundError.aspx contains an inline script without src.

SPGetCurrentSite returns unusable path

Hi,
we are in the process to migrate our Sharepoint application to https, and are currently publishing the same farm under both http and https schemes for compatibility reasons.

When the user accesses the farm via http protocol, SPGetCurrentSite returns the https url as the root url, thus breaking subsequent calls even when enabling CORS (ajax calls would require the xhr withCredentials attribute, and even then credentials are not sent when using the OPTIONS verb).

A much simpler and cleaner solution would be to check the url protocol before returning from SPGetCurrentSite; if different from the current window.location.protocol, it should be simply replaced in the returned url.

Thanks for your help,
Luca

Interested in adding dynamic filters to cascading dropdowns?

Not sure that this of general interest but I added the ability to pass a function in addition to the CAMLQuery variable in SPCascadeDropdowns. For my case, I had a static filter (Status = Open) and I had two form fields which changed the CAML query filtering (one was that the Date field is within Start and End for the item in the cascade list). I accomplished this by adding another argument to the SPCascadeDropdowns JSON input that was called CAMLQueryFunc. Then I added a few lines to your library to add a dynamically evaluated string generated by the passed function to the CAML query string.

I did this because I couldn't figure our a way to combine SPFilterDropdown with SPCascadeDropdowns to react to changes to other fields on the form that were not look-ups. For me, making a dynamic CAML query worked. I will share my code if you would be interested in adding this functionality.

SPArrangeChoices is skipping the first (perRow-1) # of items !

Hi Marc @sympmarc,
I am a great fan of your work!
When the 2014.02 was released with the fix for "choices not being saved during the page postback", the new issue started coming up i.e. initial perRow-1 number of items are getting skipped when the checkboxes are rearranged! e.g. if we want 4 checkboxes in each row then first (4-1) i.e. 3 options will be skipped!
I guess some users have reported this bug for SP2013 and some have for SPOnline, but I think this happens even for SP2010!
Upon adding a bunch of alerts, I figured out why this is happening!
In the source code, at line 3230, when you build the newChoiceTable, the first <tr> is added only when the first "closing off the row" takes place and until then there is not "tr" hence the newChoiceTable.find("tr:last").append(columnOptions[i]); line does nothing!
So,
I've made a slight change (in my personal/local copy) in that "if" condition to take care of initial/first "tr" (when i===0) and also to avoid the premature insertion of <tr></tr>.
All you need to do is, change the line 3230 as below and it will start working fine again!

                //if ((i + 1) % opt.perRow === 0) {//Original
                if (i % opt.perRow === 0) {//Fixed

Hope it helps! If it does, please feel free to implement this fix in your next build :)!!
Pankaj

SPLookupAddNew Open in Modal

I'm using SPLookupAddNew to create an add new link for one of the columns on a form. When the linked is clicked the associated form always opens up in a new tab rather than a modal dialog as desired. I've tried playing with the newWindow:(true/false) option to no avail. I've gotten it to work properly on other sites. Any ideas?

SPUpdateMultipleListItems does not work in the document library

Tell me why SPServices does not work in the document library, there are no problems in the list, but the library does not work out either, the Russian language name, tried both GUID and by name...it's still useless...
script type="text/javascript" src="/SiteAssets/jquery.SPServices-2014.02.min.js"
$().SPServices.SPUpdateMultipleListItems({
listName: "Office",
CAMLQuery: "",
batchCmd: "Update",
valuepairs: [["ValueItem", 'Update']],
debug: false,
completefunc: null
});

SPRedirectWithID not working

I'm trying to redirect a user to the edit form after they submit an item in a new form. Here's the code I'm embedding into the new form:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.js"></script>

<script type="text/javascript">
    (function () {
        jQuery(function () {
            $().SPServices.SPRedirectWithID({
                redirectUrl: "EditForm.aspx",
                qsParamName: "ID"
            });
        });

        window.PreSaveAction = function () {
            var aspnetForm = jQuery("#aspnetForm");
            alert(aspnetForm.attr("action"));

            return true;
        }
    })();
</script>

In SharePoint Online the alert in the PreSaveAction function shows that the action attribute in the form has been updated but I still get redirected to the list view after the save.

image

In SharePoint 2013 (with MDS disabled) the alert in the PreSaveAction function shows that the action attribute in the form has not been updated so, as expected, I get redirected to the list view after the save.

image

I think I'm using SPRedirectWithID as directed in the documentation.

Error in $().SPServices.SPDropdownCtl

Hello,
I have found a bug in SPDropdownCtl when used on SP2010 (possibly only on localized sites, using Italian here and I don't have an English site around for further testing).

Calls to $().SPServices.SPDropdownCtl fail when the dropdown is a required field. In this case Sharepoint sets the title attribute on the select as ' Campo obbligatorio' (which translates as ' Required field'); thus the selector $("select[Title='" + opt.displayName + "']") fails.
This causes lots of problems in filter dropdowns and other customizations which worked fine under previous versions.

Right now the workaround is to explicitly set the tooltip using jquery before activating SPServices functions, since Sharepoint:FormField doesn't allow setting the title attribute in server side code.

Issue with multile SPCascadedropdowns execution order

I have four lists, Regions, Customers, Products and Orders. The Orders list is where all the roads meet.

An order includes a Region field as lookup into the Regions list, a Customer Name field which is a lookup into the Customers list and a Product Number field which is a lookup into the Products list. In addition it inludes an Current Order field and a Previous Order field which is a lookup into this Current Order field.

Each Customer is assigned to a region (lookup field into Regions). Each customer can have several product numbers and each product number might be assigned to (bought by) different customers.

Now my aim is:
to ensure that my Previous Order numbers displayed are really restricted to the same customer and the same product number. So I would like to filter the Previous Order entries based on Customer Name and Product Number.

My according JS code is below. I use jQuery 3.6.0 and SPServices 2014.02.

Now here is my problem:

  1. Loading my [custom] NewForm will deliver the result I wish for. Customer Names are filtered based on selected Region, Product Numbers are filtered based on selected Customer Name and Previous Order numbers are filtered based on Customer Name AND selected Product Number.

  2. If I keep the Region and Customer Name and change the Product Number then the Previous Order filter list gets populated correctly and works as intended.

  3. However, once I start changing any of the other values (Customer Name or Region [incl. the automatically following downstream cascade]) it does not filter as intended. It seems that script keeps using the same Customer Name for filtering - which breaks the code/filter.

My question is:
Can anybody tell how I need to adjust my code to fix the problem and achieve the result described above?

var myJQ = jQuery.noConflict(true);
var sCamlQuery = "";

myJQ(document).ready(function() {
    myJQ().SPServices.SPCascadeDropdowns({

    relationshipList: "Customers",
    relationshipListParentColumn: "Region",
    relationshipListChildColumn: "Customer_x0020_Name",
    parentColumn: "Order Region",
    childColumn: "Customer Name",
    completefunc: function() {
		alert('Filter customer based on region');
    },
    
    debug: true
  });
  
   myJQ().SPServices.SPCascadeDropdowns({
    relationshipList: "Orders",
    relationshipListParentColumn: "Customer_x0020_Name",
    relationshipListChildColumn: "Product_x0020_Number",
    parentColumn: "Customer Name",
    childColumn: "Product Number",
    completefunc: function() {
          sCamlQuery = "<Eq><FieldRef Name='Customer_x0020_Name'/><Value Type='Text'>" + $("input[Title='Customer Name'], select[Title='Customer Name Required Field']").find("option:selected").text() + "</Value></Eq>";
    },
    debug: true
  });
   
  myJQ().SPServices.SPCascadeDropdowns({
    relationshipList: "Orders",
    relationshipListParentColumn: "Product_x0020_Number",
    relationshipListChildColumn: "Current_x0020_Order_x0020_no",
    parentColumn: "Product Number",
    childColumn: "Previous Order",
    CAMLQuery: sCamlQuery,

    completefunc: function() {
    	var value = $("input[Title='Customer Name'], select[Title='Customer Name Required Field']").find("option:selected").text();
        alert('Filter Previous Order based on product number');		
        alert('Field value is ' + value + '.');
        alert('sCamlQuery value is ' + sCamlQuery + '.');
    },
    debug: true
  });

});



SPGetListItemsJson Changing column order

Hi,
i am trying to get data using SPGetListItemsJson, after getting data the JSON is arranged in Alphabetical, is there any way to get JSON data same as viewfields Passed to SPGetListItemsJson instead to sorted by alphabets

Returning localized taxonomy field value labels (GetListItems)...

Hi Marc.

I have a list. The list has a managed metadata field. the associated termset's terms all have French labels added, in addition to English. The farm has the French language pack installed (on top of the default English), and an alternate language has been enabled (French, FR-fr) on the site collection.

If I switch languages in the UI (MUI), the taxonomy field values (labels) in the lists switch. If I get the data via SPServices, I only get the English values (labels).

Let's say I have the following two terms (and labels):
"For Sale": "For Sale" (EN), "A vendre" (FR)
"Wanted": "Wanted" (EN), "Demande" (FR)

After some experimentation using SOAP-UI, I discovered that if I add the _"Accept-Language" header _with a value of "fr-fr", I will get the French label in the taxaonmy Field's value! Ex "12;#A Vendre", which is what I'm after.

If I call GetListItems without an_ "Accept-Language" header_, I get "12;#For Sale" for the field value.

Perfect!

Is there a way for me to pass this custom header value into my SPServices call? I don't want to edit the SPServices JS file itself. I'd also not have to hook into the XHR directly to add the header if at all possible.

(FYI the hidden Note Field attached to the Taxonomy field only returns the English label for both calls, but that's ok.)

Thanks,
Chris

grunt deployment to SPOnline via webdav

In the README.md, where it talks about deploying to a SP folder:

//YourTenantNameHere.sharepoint.com@SSL/DavWWWRoot/sites/dev/Shared Documents/SPServices-dev

That did not work for me. After following this article and using backslashes, I ended up making it work:

\\YourTenantNameHere.sharepoint.com@SSL\DavWWWRoot\sites\dev\Shared Documents\SPServices-dev

Of course the backslashes need to be escaped in the me.build.json file:

{
    "deployLocation": "\\\\YourTenantNameHere.sharepoint.com@SSL\\DavWWWRoot\\sites\\dev\\Shared Documents\\SPServices-dev"
}

I'm not sure if it's just about the backslashes or also the whole configuration steps in the article, perhaps it's worth doing a bit more research and updating the readme?

SPServices.SPCascadeDropdowns - 'All' option?

Greetings!

Loving SPServices.SPCascadeDropdowns! It occurs to me that having a function based option for an (all) selection would be useful. Thinking it would be similar to the (All) option automatically created by Excel when filtering. Not sure if it is possible, or already available?

Example
State & City columns, State filters City. End form has optional input for State, just requires correct city. User isn't sure what state a particular city is in, so would prefer to scroll through the entire list of possible cities. Can select (All) to view all cities and State returns null/blank (or the correct lookup value for the city, which would be even better!)

Move documentation from Codeplex to GitHub

Codeplex is dying, but literally and figuratively. I'd like to move the documentation from Codeplex to here on GitHub. I think that GitHub Pages seems like the right mechanism to use, and I've created a gh-pages directory to contain the content.

Convert Documentation

  • Create md files for documentation pages
  • Include needed YAML headers in .md files

Specific doc files still to do

General

Core (docs/core/api/)

Copy

Lists

People

SiteData

Users and Groups

Views

WebPartPages

Webs

Spellchecker

UserProfileService

Workflow

Value-Added (docs/value-added/)

Utilities (docs/utilities/)

Generate Documentation

  • Create gulp task to take md files on input and output html
  • Create gulp task to run local dev server to verify html docs in the browser
  • Create gulp task to publish documentation to gh-pages

User profile Property fields are not auto populatng with SPServices

Hello,

I have been using SPServices in conjunction with Jquery min.js library on content editor web parts. however auto-populating feature for {User name, User department, ser contact no. etc.) are not working since last week.

Have been using jquery-3.2.1.min.Js

Any suggestions. Please help !!!

use <Method> in SPServices

I can't find any solution to write query like this in SPServices:
<View> <Method Name="<The name of the Read List method which we edited to add the Filter>"> <Filter Name="<The name of the Filter>" Value='{0}'/> </Method> <Query> <Where> <Eq> <FieldRef Name='<Name of the Filter Field>' /> <Value Type='Number'>{0}</Value> </Eq> </Where> </Query> </View>

Permission Requirements to use GetTemplateForItem to get Workflow GUID

I seem to be having an issue with GetTemplateForItem to get a list item workflow GUID.

When I run it with my account, I am able to get the workflow GUID with no issues. When I run it with a regular account, there are no errors returned, but there is also no information about the workflow returned. This is the response text:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetTemplatesForItemResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/workflow/"><GetTemplatesForItemResult><TemplateData><Web Title="TITLE" Url="https://url.com" /><List Title="List Title" Url="https://url.com/Lists/List Title" /><WorkflowTemplates></WorkflowTemplates></TemplateData></GetTemplatesForItemResult></GetTemplatesForItemResponse></soap:Body></soap:Envelope>

Basically any information about the workflow is not returned. Do you know what permissions are required to use this feature? I've tried giving the user full control over the list item (which doesn't work). The only thing that seems to work is giving more control over the entire site via Sharepoint Site Permissions (which we really don't want to do for everyone!).

It seems like 'Override List Behaviors' and/or 'Enumerate Permissions' via site permissions may allow it to run, but I haven't been able to fully test that yet.

Ideally we wouldn't need to change users full site permissions. I'm assuming there is someplace where we could give users higher permissions on a lower level that doesn't encompass the entire site.

Get user by any profile value?

Is there a way to get the user profile by a field other than the username?

I'm working on an interactive style floor map, and it would be helpful if I were able to get the user by their Office profile value.

Permissions issue with 'View Application Pages'

Hi,

Recently uncovered an issue that seems to be related to SPServices in some way. Unsure whether it is SPServices causing this or something else, but here is the issue i encountered.

When trying to use some basic SPServices functionality like obtaining logged on user i have found that it does not work if a particular sharepoint permission has been removed for the logged on user. The permission in question is "view application pages - view forms views and application pages. enumerate lists."

my code is set up to console log the logged on user with the following code......
var loggedOnUser = $().SPServices.SPGetCurrentUser();
console.log(loggedOnUser);

When i use an account that has the 'view application pages' permission, i get the expected result. However if i use an account that does not have that permission, the result is blank. There are no errors or anything.

The purpose of this requirement is to stop particular users gaining access to the layouts folder within sharepoint, according to all the documentation then the 'view application pages' is what to remove to achieve this. Unfortunately the use of SPServices to carry out certain tasks is causing a problem.

Please could some light be shed on what the issue may be?

Thanks,
Ian.

Add support for

Add a property to SPDisplayRelatedInfo to enable CAMLOnly. This means if you set a CAML query in CAMLQuery it will execute this query only, and not append an id or title filter. This makes the function very flexible in terms of bringing in related data based on arbitrary data besides the item selected - which may or may not be part of it.

use date.format in SPConvertDateToISO.js

I don't want to muck around with other people's code but wouldn't it make more sense to use Date.format in SPConvertDateToISO.js? (new Date()).format("yyyy-MM-dd HH:mm:ss");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.