GithubHelp home page GithubHelp logo

aymkdn / sharepointplus Goto Github PK

View Code? Open in Web Editor NEW
216.0 41.0 57.0 2.46 MB

SharepointPlus ($SP) is a JavaScript library which offers some extended features for SharePoint entirely on client side (requires no server install). $SP will simplify your interactions with Sharepoint.

Home Page: http://aymkdn.github.io/SharepointPlus/

License: GNU Lesser General Public License v3.0

JavaScript 99.38% CSS 0.62%
javascript sharepoint

sharepointplus's Introduction

SharepointPlus

Average time to resolve an issue Percentage of issues still open

SharepointPlus ($SP) is a JavaScript library which offers some extended features for SharePoint entirely on client side (requires no server install). $SP will simplify your interactions with Sharepoint.

Documentation

Browse the online documentation here.

Quick Start

Node Environment

npm install sharepointplus

Then:

import $SP from 'sharepointplus'

Please, make sure to read the documentation to optimize your bundle size.

Browser Only

To directly use it in a browser:

  <script type="text/javascript" src="//cdn.jsdelivr.net/npm/sharepointplus/browser/sharepointplus.js"></script>

Usage / Examples

Update all items with an "Amount" value bigger than 1000:

$SP().list('My List Name').update({
  Title:"Too expensive"
}, {
  where:"Amount > 1000"
})
.then(function(res) {
  alert(res.passed.length+" items successfully updated!");
});

Get all items with "Requestor" as the current user and with "Default Color" is "pink":

$SP().list('ListName').get({
  fields:"Title,Size",
  where:"Requestor = '[Me]' AND Default_x0020_Color = 'pink'",
  orderby:"Size DESC",
  json:true
})
.then(function(data) {
  data.forEach(function(d) {
    console.log("Model = "+d.Title+" (size: "+d.size+")";
  })
});

More information

Please visit the online documentation to know more.

sharepointplus's People

Contributors

aymkdn avatar dependabot[bot] 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

sharepointplus's Issues

Why is there no CheckOutFile method ?

Hi and thanks for this very helpfull library !

This is not an issue but I have not found the appropriate space where to write my question : why is there no CheckOutFile method ? That would be great to implement that functionnality in order to properly manage the update of file.

Many Thanks and have a nice day !

CheckOut() method

Is there a checkout() method? IF not how to update moderation status without this feature?

.webService() error 500

Hi, i'm trying to use new .webService() function like this (Sharepoint 2010):

$SP().webService({ 
  service:"UserGroup",
  operation:"RemoveUserFromGroup",
  properties:{
    groupName:"TestGroup",
    userLoginName:"DOMAIN\\login"
  }
}).then(function(response) {
  console.log(response);
});

and it's end up with "..._vti_bin/UserGroup.asmx 500 (Internal Server Error)", what can be wrong ? I also tested other opertions from usergrup service with the same result.

Remove attachments from list item

Hi Not sure if this is an issue but a feature request.

I've tried to remove attachments from List items with no luck.

I have tried the
// example for deleting a file $SP().list("My List","urltolist"}).remove({ID:4,FileRef:"my/directory/My Shared Documents/something.xls"}); example which deleted the item.

I've also tried setting the Attachments field to nothing:

$SP().list("My List","urltolist").update(
            {ID:2,Attachments:""},{success:function(items){
            items.map(function(i){
            console.log("Success");
            })
        },error:function(items) {
        items.map(function(i){
          console.log(i.errorMessage);
        })
        }});

But this appears to do nothing.
Is there a way to remove the attachments from a List item?

Error in documentation?

Aymkdn, I am trying to understand the function getuserinfo(). Your documentation states username is optional but the function shows otherwise. was this an error with the doc? I have resorted to getting the current user by SP JSOM .get_currentUser() and passing it into getUserInfo which I then pass into addressBook. .

getUserInfo:function(username, setup, fct) {

3089 if (typeof username !== "string") throw "Error 'getUserInfo': the first argument must be the username";

Ultimately I want the current users Name, Email and Phone.

List Add error/success issue?

I seem to having some issues with the Add method for the List. The function never seems to log to the console, neither on success nor on error? Sometimes my add succeeds while at other times it fails, but I get no indication of why it failed?

The Add function seems to be from row 1724 in SharepointPlus 3.0.8 but I can't see the ":error" section in the ajax call or is this done in a different way?

$SP().list("My List",).add({Field1:"Value1",Field2:"Value2"}, {error:function(items) {
  for (var i=0; i < items.length; i++) console.log("Error: '"+items[i].errorMessage); // the 'errorMessage' attribute is added to the object
}, success:function(items) {
  for (var i=0; i < items.length; i++) console.log("Success: (ID:"+items[i].ID+")");
}});

UPDATE: I created a new Custom List and now it seems to work?

Addnig fields to createFile not working

Hi,

I am trying to create a file in SharePoint 2007. I can create the file however data in the fields option are not being adding to the file.

My code is:

$SP().list("DocumentLibraryName", "SiteURL").createFile({
content: content,
encoded: true,
filename: name,
destination: destination,
fields: {
"Document_x0020_Type": docTypeVariable,
"IA_ID_Code": iaIDVariable
},
after;function() {
}
});

I am using version SharepointPlus v3.0.4

Do you have any other solutions for me to achieve this?

Thanks,
Matt

List getAttribute

Hi, thankyou for such a nice work. I am working with List and in IE9 iam getting an error Like "Object doesn't support property or method 'getAttribute' " can anyone please guide me on this.

Question: .Get Where claus on a lookup field

Been playing around with your library and its meeting a lot of my needs. Great Job!

I do have a question that I just seem not to be able to find an answer to. I need to filter a lot of my lists with specific values from a multi choice or lookup fields. How do you write the where claus to retrieve all the records that have a specific value in a multiple choice field?

Join Using a LookupField

Hi There!

First of all, thanks for the amazing library, has been very useful here.

I am trying to make a Join using a Lookup Field. I made an simple example below to illustrate it.

Lets assume two simple lists, one called lstPeople and one called lstCompanies. The relation between the lstCompanies and the lstPeople is an 1-n relation. I am trying to join them using a lookup value, which is called Company and is a column under lstPeople.

Please see below:

List 1: lstPeople
Columns:
ID
Value
Company (An lookup value that references the lstCompanies)

List 2: lstCompanies
Columns:
ID
Value

I tried many appraches, but no success yet. Here is one example of what I am trying:

        $SP().list("lstPeople").get({
            fields:"ID, Person, Company",
            join:{
                list:"lstCompanies",
                where: "ID = '1'",
                fields:"ID, Value",
                on:"'lstPeople'.Company = 'lstCompanies'.ID"
            }               
        }, function getData(data) {
             console.log(data);
            for (var i=0; i<data.length; i++) 
            {
                console.log(data[i].getAttribute("lstPeople.Company"));  
            };
        });     

Thanks in advance!

$SP.List() Update method with multiple fields

I am trying to update multiple fields in an individual record with a where clause. two fields are look-ups. It seems to work intermittently updating each field individually. If I re-run the code I can get the next one to update (sometimes). i am passing in the correct look-up format ID;#Stringvalue. they are single value look-ups.

If I try to wrap the fields in an array .update( [{field: value},{field: value}], {where: value}) and make a single call it does not work at all.

I assume unlike the update() with ID method the update() with where can only handle individual columns one at a time, is this correct? If not, how do I do a multiple field update with look-up columns?

username documentation

It took me one day to realize that the accountName parameter for the $SP().usergroups function should be formatted as "i:0#.w|domain\\login" for Sharepoint 2013 instances and not simply domain\\login.

I noticed from checking the isMember function so I guess would be better to update the documentation for all the function that require an username (where not already done as per isMember and getUserInfo:

createFolder

Question from @astatke :
ยซ Thank you for the great js libraries. I am using your createFolder function which is great. Having said that I do not want my newly created folders have their permission inherited from the parent i.e. the document library. As you know, new folders or files created within a library have their permission inherited from the parent. How do I be able to create new folders with broken inheritance? ยป

getAttribute

hi
i worked with version 3.0.10...
but recently i make decision to use version 4
but there is error:
getAttribute("....") is undefined...
after change the version to 3.0.10 every thing worked correctly.

SharePoint Lists: info, get, update, add, delete ...

I am testing out how to get, update, add and delete items in a custom SharePoint list. I managed to call the "get" method successfully, which is when I noticed there appears to be a difference between the DisplayName and StaticName. By calling "info" I managed to get the DisplayName, The attributes in the data array which was returned by "get" look something like this: ows_title, ows_***? I also can't seem to find any ID which will be required by the "update" which I have not tried yet. It would be nice if there were some examples showing how to do this? How to make sense from what the get/info methods return?

Working with Document Library (Not Lists)

I need to perform CRUD operations on a Document Library, with sub folders. I'm trying to use the code below to iterate over the Document Library (just as a starting point). Do I need to add or change anything other than the library name? Does it matter that the site is a subsite? The API works fine for regular Lists. Thank you!

$SP().list("DDR").get({fields: "BaseName,FileRef,FSObjType",
folderOptions: {show: "FilesAndFolders_Recursive"}});

The value of the property '$SP' is null or undefined, not a Function object

Hi. I'm getting the error on all your sample I've ttried to run so far, so I am uanbel to get them to run for me, including simple non-dependent scripts like:

$SP().lists(function(list) {
//for (var i=0; i<list.length; i++) console.log("List #"+i+": "+list[i]['Name']");
for (var i=0; i<list.length; i++) console.log(i);
});

I have a good link to your library which is in the same location where I maintain a funciton jquery library:

<script src="/sites/localresearch/Style%20Library/Scripts/SharepointPlus-master/sharepointplus-3.0.9.min.js"></script>

so I am wondering if there is someting fundamental you could suggest that i might be doing wrong. it seems like the js I am writing cannot see the sp file you have created. tx -dave

Can not read property 'length' of indefined when use setup.page

Example:
$SP().list("My List").get({fields:"ID",orderby:"ID DESC",rowlimit:1,paging:true,page:1}, function(data) { console.log("last ID : "+data[0].getAttribute("ID")); })

When you specify a page number 1, then all is well.
other numbers of pages writes an error
sharepointplus-3.0.10.js: 1134 Uncaught TypeError: Can not read property 'length' of indefined
please tell me what is wrong?

error:
image

ok:

image

Error Handling

Hi there,

I submit this fix to createFile so that it has better error handling. It is attempting to throw an error after Ajax call but nothing can catch it because the call is asynchronous.

success:function(data) {
         var a = data.getElementsByTagName('CopyResult');
          if (a && a[0] && a[0].getAttribute("ErrorCode") != "Success") 
          {
            if (typeof setup.after == "function") setup.after.call(_this, "Error 'createFile': "+a[0].getAttribute("ErrorCode")+" - "+a[0].getAttribute("ErrorMessage"));
            //throw "Error 'createFile': "+a[0].getAttribute("ErrorCode")+" - "+a[0].getAttribute("ErrorMessage");
          }
          else 
            if (typeof setup.after == "function") setup.after.call(_this);
        },        
        error:function(jqXHR, textStatus, errorThrown)
        {
            if (typeof setup.after == "function") setup.after.call(_this, errorThrown);
        }

async operations

Hi, I'm trying to make a function that updates some items on a list and I want that the function returns only when all the items have been updated, because $SP().list("xxx").update is async I don't know how to know when all the operations end.

Note: I've seen that I can group the updates and execute an after function but I have other functions where I have add and update operations and I want to know when all the operations end.

Note 2: another problem is if I call my function from another function and I want to wait until all the operations end. I can group the update functions and execute the after function but before the after function is executed the function ends...

` $scope.saveConfigurations= function () {
for (var i in $scope.configurations) {
if (x)
$SP().list("xxx").update({...
else
$SP().list("xxxx").add({
}
}

$scope.saveActivities = function () {
$scope.saveConfigurations();
// I want to expect that all operations from saveConfigurations are done
// do the rest of statements...

}

`

any clue?

create a Excel file with hebrew characters

hi,
first thank you for the hard work ๐Ÿ‘

ive just started to work with your library and im trying to export a table to xls but it seems like the encoding system you are using delete all hebrew (and posibly also arb)
the file is saved but the data is missing from the places were theres hebrew.

dan

Issue with .createFile function

I have successfully implemented your code in two of my three environments (Dev and Staging), but when I add your code to my Production environment, the .createFile function does not work.

This is not to say that the function failed; more accurately is that the function appears to be skipped. Code after the function is called runs fine, but there are no results from using the createFile function. I don't receive any errors. The only thing that I can think of is that there are some services/dependencies that are not available on Production.

Your insight into this is appreciated.

CheckIn file issue

There is an issue checkin file, refer to line 1751

var soapEnv = _this._buildBodyForSOAP("CheckInFile", '<pageUrl>'+setup.destination+'</pageUrl><comment>'+setup.comments+'</comment><CheckinType>1</CheckinType></CheckInFile>');

double tag CheckInFile

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <CheckInFile xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <pageUrl>https://jpempresas.sharepoint.com/sites/GCT/centroDocumental/Documents/20160509__EvidenciaCttosCargados.xlsx</pageUrl> <comment>Nuevo documento</comment> <CheckinType>1</CheckinType> </CheckInFile> </CheckInFile> </soap:Body> </soap:Envelope>

Question: get permissions

I would like to make it visible which SharePoint groups have which access level to the various document libraries and lists. Folders would be great too if possible?

Correct me if I am wrong, but I don't think SharePointPlus currently provides a way to get the assigned permissions for the current site or a specific library/list?

After a bit of Googling I stumbled on this article: https://zieglers.wordpress.com/tag/permissions-asmx/ which mentioned the GetPermissionCollection method of the permissions.asmx web service?

Are there plans to add this to SharePointPlus?

Using this in Node environment

Hi,

Is it possible to use this library in a node project?

I am importing the library using require() like the following but get an error when the app loads:
let $SP = require('../../../public/js/sharepointplus-3.13.min.js')

$SP().list(_LIST,_DATAURL)
      .get({
        fields:"P_NC,P_Ser,P_SO",
        orderby:"P_SO"
      },function(data) {
      let _LISTGROUP = data.map((item) => {
        return {
          'serv': item.getAttribute("P_NC"),
          'ser':item.getAttribute("P_Ser"),
          'so':item.getAttribute("P_SO"),
        }
      })
      this.setState({
        'material':  _LISTGROUP
      })
    });

This compiles OK but when the code runs I get:

Uncaught TypeError: $SP is not a function
    at Content.componentWillMount (Content.js:21)
    at ReactCompositeComponent.js:348
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:347)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:258)
    at Object.mountComponent (ReactReconciler.js:46)
    at ReactDOMComponent.mountChildren (ReactMultiChild.js:238)
    at ReactDOMComponent._createInitialChildren (ReactDOMComponent.js:697)
    at ReactDOMComponent.mountComponent (ReactDOMComponent.js:516)
    at Object.mountComponent (ReactReconciler.js:46)

I realize this library is client side (which I need) but is there anyone who has successfully integrated the library with ES6 modules?

Thanks in advance

Issue with createFile Method

Hello,

I have a problem with the createFile method. It seems that it doesn't do anything : code after is running perfectly but I don't have any result on my Sharepoint site and it doesn't run the function put in the after attribut either.
I am using Sharepoint Foundation 2010 for my SharePoint site : do you think it could cause the problem ?

Thank you for your help,

Issue with checkin method

Hi,

I tried to use the checkin method after the creation of an excel file but it gives me a error :
in 3.13/sharepointplus.js line 20 col 4127
_spPageContextInfo is undefined

here is my code :

var dest = "http://monsite.com/file.xls";
$SP().createFile({content:table,destination:dest,url:"https://mysite.com",after:function(){alert("File created");}});
$SP().checkin({destination:dest});

Do you have any idea what can cause that ?

Thank you for your help

Left Join

Hi
can i have Left Join or Right Join on 2 list?

Update a multivalued field

Hello,
First of all, thank you for the wonderful library you've made. It made my programming a lot easier.

I've been trying to find a way to update a multivalued field of an item on a SP list.
For example I've tried to update with lines such as:

$SP().list("lst_Errors").update({ID:31, Risks: [570, 572]})
$SP().list("lst_Errors").update({ID:31, Risks: ;#570;#572;#"})
$SP().list("lst_Errors").update({ID:31, Risks: '570, 572'})
$SP().list("lst_Errors").update({ID:31, Risks: '#570; #572'})

Is it possible to do what I'm trying?
Thank you very much.

Bug? people method

I came across a problem when trying to get a user's information from the people method.

When it is trying to evaluate:

if (value&&value.length>=1) value=value[0].firstChild.nodeValue;

I had problems with it, not with all users but with several of the ones I was testing. Index 32 of the "for" statement threw an undefined "nodeValue" error. I managed to skip this line by adding the following:

//line 2976
if (value&&value.length>=1) {
if (value[0].firstChild !== null)
value=value[0].firstChild.nodeValue;
}

The only difference I found from the users I could get the information and the ones I couldn't is that the node Privacy tag, being "Public" the ones I could get the info and "NotSet" the ones I couldn't.

I'm no expert on JavaScript but that's how I managed to fix it from my end. Is this a correct approach to make it work?

Please let me know
Ivan

Promises?

I am looking for information on how to use SharepointPlus to get list info with a Javascript promise. My code works fine, but I need to use the list info returned to get more data from sharepoint. Unfortunately, the query isn't done before the next one starts so I am getting nulls returned. Here is the code I have, can you provide an example of how to use a Javascript Promise with it?

$SP().list("Friends of the Ship").get({
fields:"Title",
groupby:"Title",
view: "Platform"
}, function getData(data) {

//Getting unique values from the array
Platform = GetUnique(data);
});

Thanks!
Stuart

global variable

First I want to say that finding SharpointPlus library has made my SharePoint development a lot easier. Thank You for sharing.

I'm trying to assign a global variable from SP+:

function getValue() {
var Value = ""

    $SP().list("list").get(function(data) {
      for (var i=0; i<1; i++) 
           Value = data[i].getAttribute("Title");
      console.log (Value); //get results, returns first Title record
    });
    return Value
}   
console.log(getValue()); //no results, returns "" (blank)

Inside the SP+ function the value returns, however outside of the function, I get "".

I'm assuming this is a basic request, but I can't seem to assign a variable outside of the $SP call.

Thanks for your help.

Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined

I have built an app that traverses the entire SharePoint and prepares an excel report about the files and their metadata. Kind of like a snapshot of the current file system on the SharePoint. Sometimes however I will get this error, especially when I go around 100 000+ files on a very big SharePoint site.
image

Any help will be great.

NTLM

Hi,
Just curious is there any way to provide login credentials for the Sharepoint site with the SOAP services ? I was trying this and getting 401 - Unauthorized fired back from the server.

Thanks

Starting with SPPlus

I'm new to SP Plus. I have a custom list and form and made this test script (sorry attached it as an image as the form wouldn't render code)

fct

I've tried variation of the field "Work Pack", such as "@Work_x0020_Pack" and "Work_x0020_Pack"

I want to take the field "Work Pack" and on start (when the function is called) apply the value "hello" to it, but all I get is the undefined exception. I know the libraries are accessible because the function "whoami" works.

Is there any special trick to getting fields read? Is SP Plus supported on customized forms?

exception

custom form

Regards,
-m

Strange behavior in IE11 Version 11.0.9600.18449

Hi
i have created on one of our sharepoint sites a simple call to a sharepointlist. This one is to create a little HowTo. Because i have already created a fully functional dashboard with sharepointlist datas on another site. But this one is strange.

when i try to do a simple View command i receive in IE 11 an error:
"XML5619: Fehlerhafte Syntax in einem Dokument. Zeile: 1, Spalte 1" and the call stops.
When i check the console under network i see an Error 404:
Respone from Webs.asmx:
<?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><WebUrlFromPageUrlResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"><WebUrlFromPageUrlResult>https://xy.ch/projects/advanced-sharepoint-things/charts</WebUrlFromPageUrlResult></WebUrlFromPageUrlResponse></soap:Body></soap:Envelope>

Webs Demand in IE:
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><WebUrlFromPageUrl xmlns='http://schemas.microsoft.com/sharepoint/soap/' ><pageUrl>https://xy.ch/projects/advanced-sharepoint-things/charts/SitePages/test_6.html</pageUrl></WebUrlFromPageUrl></soap:Body></soap:Envelope>

i have removed our domainname

Views Demand in IE is:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetViewCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>Demoliste</listName> </GetViewCollection> </soap:Body></soap:Envelope>

Repsonse from Views.asmx:
404 FILE NOT FOUND

and here is the path to the listfile:
https://xy.ch/projects/advanced-sharepoint-things/charts/Lists/Demoliste/AllItems.aspx
i have removed our domainname
Listname is: "Demoliste"
the View is: "Alle Elemente" or "dataview"

this is how i'd like to get the columns:
$(document).ready(function(){ $SP().list("Demoliste").view('Alle Elemente',function(data) { var array = []; for(var i=0; i<data.fields.length;i++){ array.push(data.fields[i]); } console.log(array); }); });

the same Page shows me in FF the Array with the column titles, so no error - but with IE it did not take this list. Whats wrong here?

I've tried it out with SP Plus Version 3.12 & 3.13 (because my working dashboard runs with 3.12)
The list is saved on a subweb (same level as the html file which calls it).

thanks for this great script / framework - its very nice :-)
but have you any clue why that did not work?

dual license / license change

Hi, same guy from twitter @Shahab_Afshar

According to what I've learned about opensource licensing, there are two major movements:
(1) The permissive movement: BSD / MIT / etc.
(2) The CopyLeft (the restrictive type): GPL 1/2/3

(1.5) the LGPL / Apache License / etc. (something in-between)

while the copyleft licensing (GPL) won't allow using your software with non-opensource. Since using your library (GPL) with other software (even at run-time) requires the whole stack to be opensource (which is not possible with lots of projects).
Therefore I recommend to change the license to something like LGPL which is designed for opensource libraries and allows using them with closed source software, or even better, a dual license such as MIT/BSD would be tremendously helpful in using and expanding the lovely $SP (which is the definite means of what __api should have been...)

So this will let people like me use your library in their projects and in SharePoint without worrying about the licensing issues, and still keep it opensource.

So, please please PLEASE give us access to the library with a more permissive license type.

The value of the property '$SP' is null or undefined, not a Function object

Hi Aymkdn,

I'm very sorry if the following is a newbie question but I can't get sharepointplus working :(
Not even simple function calls are working as I always get the above mentioned error.
I read the documentation, checked your examples as well as the already closed issues.
Do I make any essential error?
I'd be very happy if you could help me!

Code example:

<script type="text/javascript" src="https://webapplication/sitecollection/SiteAssets/Scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://webapplication/sitecollection/SiteAssets/Scripts/sharepointplus-3.14.min.js"></script>
<script>
function testSPPlus(){
	try{
		$SP().list("Announcements","https://webapplication/sitecollection/subsite/").get({
			fields:"Title"},function getData(data){
				for (var i=0; i<data.length; i++){
					console.log(data[i].getAttribute("Title"));
				}
			});
	}
	catch(ex){
		alert(ex.message);
	}
}
testSPPlus();
</script>

Thanks in advance and best regards,
afripat

Creating a plug in for start workfow

useful to create a plug in or modification of the .js file to start Nintex workflows on SP 2010. I am trying to use the SOAP message that works for me otherwise and parameterize it and wrap it with your code so people can use SP+ to start Nintex WF's. Can you suggest to me where I need to correct the following effort to effect this? -tx dave

@name $SP().list.startWorkflow
@function
@description Manually start a work (that has been set to be manually started) (-untested with Sharepoint 2007-)

  @param {Object} setup
    @param {Number} setup.ID The item ID that tied to the workflow
    @param {String} setup.workflowName The name of the workflow
    @param {Array|Object} [setup.parameters] An array of object with {name:"Name of the parameter", value:"Value of the parameter"}
    @param {Function} [setup.after] This callback function that is called after the request is done
    @param {String} [setup.fileRef] Optional: you can provide the fileRef to avoid calling the $SP().list().getWorkflowID()
    @param {String} [setup.workflowID] Optional: you can provide the workflowID to avoid calling the $SP().list().getWorkflowID()

  @example
  $SP().list("List Name").startWorkflow({ID:15, workflowName:"Workflow for List Name (manual)", parameters:{name:"Message",value:"Welcome here!"}, after:function() {
    alert("Workflow done!");
  }});
**/
startWorkflow:function(setup) {
  // check if we need to queue it
  if (this.needQueue) { return this._addInQueue(arguments) }
  if (this.listID == undefined) throw "Error 'startWorkflow': you have to define the list ID/Name";
  if (this.url == undefined) throw "Error 'startWorkflow': not able to find the URL!";

  setup = setup || {};
  setup.after = setup.after || (function() {});
  if (!setup.workflowName && !setup.workflowID) throw "Error 'startWorkflow': Please provide the workflow name!"
  if (!setup.ID) throw "Error 'startWorkflow': Please provide the item ID!"

  // find the FileRef and templateID
  if (!setup.fileRef && !setup.workflowID) {
    this.getWorkflowID({ID:setup.ID,workflowName:setup.workflowName,
      after:function(params) {
        setup.fileRef=params.fileRef;
        setup.workflowID=params.workflowID;
        this.startWorkflow(setup)
      }
    })
  } else {
    // define the parameters if any
    var workflowParameters = "<root />";
    if (setup.parameters) {
      var p;
      if (setup.parameters.length == undefined) setup.parameters = [ setup.parameters ];
      p = setup.parameters.slice(0);
      workflowParameters = "<Data>";
      for (var i=0; i<p.length; i++)
      workflowParameters += "<"+p[i].name+">"+p[i].value+"</"+p[i].name+">";
      workflowParameters += "</Data>";
    }

var webMethod = srcUrl + '/_vti_bin/NintexWorkflow/Workflow.asmx';
var soap= "" +
"<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd="http://www.w3.org/2001/XMLSchema\" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/\">" +
"soap:Body" +
"<StartWorkflowOnListItem xmlns="http://nintex.com\">" +
"" +setup.ID+ "" +
"" +this.listID+"" +//need to add HARDCODE
"" + setup.workflowName + "" +//IS THIS OK CAN USE ALERT TO TEST THSE?
"" +workflowParameters+ "" +
"" +
"/soap:Body" +
"/soap:Envelope";
/* ORIGINAL WOW CODE
var body = "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd="http://www.w3.org/2001/XMLSchema\" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/\">"
+ "soap:Body<StartWorkflow xmlns="http://schemas.microsoft.com/sharepoint/soap/workflow/\">"
+ ""+setup.fileRef+""
+ ""+setup.workflowID+""
+ ""+workflowParameters+""
+ "/soap:Body/soap:Envelope";

               */
    // do the request
    var _this=this;
    var url = this.url + "/_vti_bin/NintexWorkflow/Workflow.asmx";
    jQuery.ajax({
      type: "POST",
      cache: false,
      async: true,
      url: url,
      data: body,
      beforeSend: function(xhr) { xhr.setRequestHeader('SOAPAction', 'http://schemas.microsoft.com/sharepoint/soap/workflow/StartWorkflow'); },//IS THIS BREAKING IT?
      contentType: "text/xml; charset=utf-8",
      dataType: "xml",
      success:function(data) {
        setup.after.call(_this)
      },
      error:function(jqXHR, textStatus, errorThrown) {
        setup.after.call(_this)
      }
    });
  }
  return this;
},

Using paging throws exception

Hi, Thank you for your awesome library :)
However I have one issue using the paging feature
(Honestly I don't know if I do anything wrong or what)

I currently use version 3.0.7 and when I use row limit with paging true it throws an exception (jQuery 1.10.2)

Uncaught TypeError: Cannot read property 'length' of undefined

Simplified Code:

$SP().list("Pages","/en/MediaCenter/News/archive").get({orderby:"ArticleStartDate ASC",rowLimit:2,paging:true},function(data) { 

});

Thanks.

Error thrown when trying to load another sharepoint site

Line 1424 : this.url is always undefined and throws the error even if the site is up and accessible.

Could you please tell me where's my problem when i do this :
$(document).ready(function(){
$SP().lists({url:"http://espace-dev"},function(list){
for (var i=0; i<list.length; i++)
{
console.log("List #" + list[i]['ID'] + ": " + list[i]['Name']);
}
});
});

The console shows nothing and bug at line 1424. I know the domain espace-dev exists since i created it.

Thanks again !

Add Webparts Broken

I recently added your jquery plugin, and first impression is awesome FYI. I look forward to using this more.

I did run into an issue when trying to add the reference to the SP2010 master page. Some functionality, like adding a webpart ceased to work. Additionally, the webpart menu is unusable. The webpart navigation does not truncate (assume using an array).
spplus error

I found this article on the topic: http://stackoverflow.com/questions/7568638/my-custom-javascript-is-conflict-with-sharepoint-javascript-sharepoint-2010 I downloaded the uncompressed JS file (v3.0.11) and removed the first if statement for !Array.prototype.indexOf just to test. The issue resolved itself. Is this a bug or is there a workaround so we can reference SharePointPlus in the masterpage?

We call a ton of js plug-ins, but this behavior only came when we added SharePointPlus to the code calls.

<script type="text/javascript" src="/_layouts/archetonomy/mdd/js/jquery.min.js"></script> <script type="text/javascript" src="/_layouts/archetonomy/mdd/js/megadropdown.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/jQuery/jQuery%20UI/jquery-ui.min.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/AngularJS/angular_legacy.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/AngularJS/ui-bootstrap-tpls-0.11.2.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/jQuery/Clearable%20Textbox/jquery.clearable.js"></script> <script type="text/javascript" language="javascript" src="[URL]/_layouts/Infowise/SmartActionPro/smartactionprosupport.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/jQuery/jquery.SPServices-2014.01.min.ssl.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/jQuery/sharepointplus-3.0.11.js"></script> <script type="text/javascript" language="javascript" src="[URL]/CodeLibrary/Gritter/js/jquery.gritter.min.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/jQuery/jquery.hoverIntent.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/ONBFunctions.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/Modern-Buttons/js/m-dropdown.min.js"></script> <script type="text/javascript" language="javascript" src="[URL]/SiteAssets/CustomCode/Modern-Buttons/js/m-radio.min.js"></script>

Object doesn't support property or method 'addAttachment' error on list

Hi,

Great library by the way!

My issue is with the addAttachment method on a sharepoint list .

I am using the off-the-shelf example provided on the site which is as follows:

$SP().list("List_Name","http://collaboration.company.com/projects/office_site/sub_page/").addAttachment({
        ID:1,
        filename:"helloworld.txt",
        attachment:"U2hhcmVwb2ludFBsdXMgUm9ja3Mh",
        after:function(fileURL) {
          alert(fileURL)
        }
      });

Only change is I have added the url to the list as I am using the library to upload files from a clientside webapp and so am 'outside' the destination site.
However when I debug (using IE11 - unfortunately a necessity) without even getting into the setup object within the addAttachment() method I get the error in subject line.

I've setup the list to allow attachments however think the issue lies in my setup as the server doesn't appear to be ever queried here.

Adding, updating and removing list items works fine apart from this.

I am using the following cdn:
https://cdn.jsdelivr.net/sharepointplus/3.13/sharepointplus.min.js

Any help here would be appreciated.

Get users in group using groupMembers function (logged with read-only user permission).

Background

In SharePoint Online, I'm using SharePointPlus for get info across lists and users.
I'm currently developing a functionality for query certain info from users (i.e PreferredName, AccountName, Picture, Birthday, etc) from users assigned in a group.

Current situation

After test with a admin user credentials all works perfectly. However, since the functionality must be available for any user of the site, I had to make another tests with a user who has read-only permissions:

I'm using groupMembers function for this purpose. When I execute the following code:

// Calidad is the name of the group.
$SP().groupMembers("Calidad", function(members) {
  for (var i=0; i < members.length; i++) console.log(members[i]);
});

The response is:

POST https://<site>/<subsite>/_vti_bin/usergroup.asmx 500 (Internal Server Error)
Uncaught TypeError: Cannot read property 'firstChild' of undefined

In the "Source" tab, the error occurs in the "sharepointplus.js" file at line 2933

Here is the screenshot and here is the specific line if there're problems with the screenshot:

// any error ?
var error=req.responseXML.getElementsByTagName("errorstring");
if (typeof console === "object") console.error("Error 'groupMembers':"+error[0].firstChild.nodeValue);

When I print "using the console.log command" the error variable, it shows a empty object = [] when the if condition is true. i.e here: error[0].firstChild.nodeValue

This situation doesn't happen with whoami function.

I'm wondering if anyone had seen a similar situation.

How to add to a list without logging in?

Hi Aymeric,

So what I am trying to do is pass information from one list to another in SharePoint. It works in a similar way to a shopping cart. As you can see from this picture, each record in this list named "Artifacts" has a button. When that button is presses, information from that record is saved to a cookie. Later on, the cookie is read and the information from the cookie is added to a new list named "Requests."

I am currently using this library as it is very simple and straightforward to add a new record using this line of code: $SP().list("Requests").add(...);

My question is, is there a way for your library to be able to add a new record without the user being logged into the website? If I am not signed in, no information gets added to the list and a popup message appears asking for login credentials.

Any help would be greatly appreciated.

Thanks.

capture

CORS issue in chrome

Hi - Not sure if this is an "issue" but I wanted to ask how CORS is handled in Chrome as when i attempt to get list data I get the following:

XMLHttpRequest cannot load http://collaboration.<company>.com/projects/<site-name>/_vti_bin/Lists.asmx. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 401.

Clearly this library is supported on Chrome so I must be doing something wrong (no issue on IE11)

How do I do this request on chrome?

Thanks (sorry for opening issue I didn't know how to ask otherwise)

Checkin issue

Hi,
I am using SharePointPlus v3.14, and I am facing a strange error with the checkin function
I ged allways "Error 'checkin': not able to find the URL!", even if I add url property to setup parameter.
$SP().checkin({url:"http://mySharepointIntranet",
destination: "/MyLibrary/Folder/file.ext",
comments:"Automatic check in",
after:function() {}
})

Thanks

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.