Blog

How to resolve the 5000 item limit

On 24/01/2022


    var firstItems = listLocation.web.getList(listLocation.listUri).items.select('ID').top(1).orderBy('Id').get();
    var lastItems = listLocation.web.getList(listLocation.listUri).items.select('ID').top(1).orderBy('Id', false).get();
	const allMySites  = [];

    if (firstItems.length === 1 && lastItems.length === 1) {
      const firstId: number = firstItems[0].ID;
      const lastId: number = lastItems[0].ID;
      let startId = firstId;
      let endId = firstId + 5000;
      do {
        let mySites: ISite[] = await listLocation.web.getList(listLocation.listUri).items

          .select('ID', 'Title', 'Url')
          .filter(`Id ge ${startId} and Id lt ${endId} and ProprietairesPeople/Id eq ${userId}`)
          .expand('ProprietairesPeople')
          .orderBy('Title')
          .top(5000)
          .getAll(); 

          allMySites.push(...mySites);
          startId = startId + 5000;
          endId = endId + 5000;
      }
      while (endId < lastId);
    }
    return allMySites;


Add User To Group With Rest

On 20/09/2021

Add User To Sharepoint Group With Rest

 


var fdi = fdi || {};

fdi.post = function(request, data, urlWeb, retFunction, expecedcode=200, odata="verbose"){
    var url = _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo?&select=FormDigestValue";
	var xhr = new XMLHttpRequest();
	xhr.open('POST', url, true);
	xhr.setRequestHeader("Accept", "application/json; odata=nometadata");
	xhr.onload = function () {
		if (xhr.status === 200) {
			console.log(url + " : success");
			var d = JSON.parse(xhr.responseText);
            console.dir(d.FormDigestValue);

            var viewXml =  "" +
                    "" +
                    "" +
                    "" +
                    "";
            
            var req = { "query" :{"__metadata": { "type": "SP.CamlQuery" }, "ViewXml": viewXml}};
            var xhrPOST = new XMLHttpRequest();
            var reqUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(5)/users";
            //debugger;
            xhrPOST.open('POST', reqUrl, true);
            xhrPOST.setRequestHeader("Accept", "application/json; odata=" + odata);
            xhrPOST.setRequestHeader("content-type", "application/json; odata=" + odata);
            xhrPOST.setRequestHeader("X-RequestDigest", d.FormDigestValue);

            console.log("onload");
            xhrPOST.onload = function () {
                
            console.log("onload ok");
                console.dir(JSON.parse(xhrPOST.responseText));
            }
			
			var metadata = {  
    __metadata: {  
        'type': 'SP.User'  
    },  
    LoginName: 'i:0#.f|membership|fred.ddiet@test.com'  
};  JSON.stringify(metadata)
            xhrPOST.send(JSON.stringify(metadata));
            console.log("sent");
		}
		else {
			console.log("error");
			console.log(xhr.status);
			console.dir(xhr);
			console.dir(xhr.responseText);			
		}
	};
    xhr.send();
};

fdi.post();

PowerAutomate Add User To Group

On 19/09/2021

Powerautomate add user to sharepoint group

Ajouter un utilisateur dans un groupe sharepoint en REST avec powerautomate

{"__metadata":{"type":"SP.User"},"LoginName":"i:0#.f|membership|@{variables('emailToAdd')}"}
{
  "siteUrl": "https://vvvvvvvvvvvvvvv.com",
  "Accept": "Accept",
  "ApplicationJson": "application/json; odata=verbose",
  "ContentType": "content-type"
}

 

Getassociatedmembers

 

Addusertogroup

 

Gulp Bundle Issue Cannot Read Property Id Of Undefined

On 08/06/2021

Gulp bundle issue  : Cannot read property 'id' of undefined

Gulp bundle issue  : Field 'browser' doesn't contain a valid alias configuration

Gulp bundle issue  : sub task errored after

 

Check that in your tsconfig.json, you've got this below : 


"include": [
    "src/**/*.ts", "src/**/*.tsx"
  ],

and not : 


"include": [
    "src/**/*.tsx"
  ],

PowerApps Build String To Link

On 31/05/2021

Powerapps build your string to creae an html link

 


<div style="background-color:#000000;width:100%;"><code><a href="https://mySP.sharepoint.com/sites/DfSite/Lists/Initiatives/DispForm.aspx?ID=&quot;; InitiativeId; &quot;" style="color:#FFFFFF;height:100px">&quot;;SelectedInitiative.Titre;&quot;</a></code></div>
 

 

Buildlink

Powerautomate Caml Query

On 27/05/2021

Powerautomate Caml Query

Camlquery

Powerautomate Add Comment To ListItem

On 27/05/2021

Add comment to ListItem with powerautomate (http Sharepoint request)

Addcommentonitem


{
  "Accept": "application/json; odata=verbose",
  "content-type": "application/json; odata=verbose"
}

PowerAutomate Update ListItem HTTP REST

On 27/05/2021

Update a list item with http request with powerautomate

Updateitem 1

 

 


{
  "Accept": "application/json; odata=verbose",
  "content-type": "application/json; odata=verbose",
  "X-HTTP-Method": "MERGE",
  "If-Match": "*"
}