by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Andrew Koltyakov
    @koltyakov
    Office 365 dev program allows getting renewable SPO E5 subscription for free for dev purposes, btw.
    Zach Rachedi
    @Shisuki
    Thanks I'll look into it!
    Andrew Koltyakov
    @koltyakov
    With npm run start SPPP launches webpack dev server with proxy to SP API. So an SPA app can be not deployed at all during dev. But a dev tenant is anyways safer and is a field for experiments and tests.
    A default generated project includes sample webpart with minimal binding to get started working with API requests.
    Zach Rachedi
    @Shisuki
    Nice so I can test what I'm trying to do on local before publishing! (Sorry if i'm taking too much of your time it's okay if you're busy)
    Andrew Koltyakov
    @koltyakov
    However, in the end of the SP is not a simple platform and there is a large field for learning.
    Zach Rachedi
    @Shisuki
    Yes I'm aware of that, right now the team only needs me for my general JS knowledge in general and we're using PNPJS and learning as we go
    Andrew Koltyakov
    @koltyakov
    No problem thats why we’re here to share some knowledge. Happy coding and learning. SP can bring lots pain and joy when something begin to work.
    Zach Rachedi
    @Shisuki
    Thank you so much! I'm getting to experience that
    I'll let you know if I need any more assistance
    @koltyakov you said it's better to start using SPFx because it's more modern, do you have anywhere you can point to so I can start learning it ?
    The website is still new with only a dozen pages so I think refactoring it wouldn't be that hard
    Zach Rachedi
    @Shisuki
    Thanks
    Andrew Koltyakov
    @koltyakov
    When it comes to Modern UI, SPFx is the only way for dev customizations. E.g. you can place any web part on a modern page, but SPFx. You can’t apply user custom action to modern pages if it is not an application customizer.
    Zach Rachedi
    @Shisuki
    Yeah I see, better switch to it sooner than later
    Andrew Koltyakov
    @koltyakov
    There are places even in SPO for classic, but it’s mostly a compromise or an intermediate point on the way migrating to modern. Which one day will be the only option on SPO. Vendor invest into Modern lots of affords but nothing to classic these days.
    Zach Rachedi
    @Shisuki
    Which is understandable, the web is evolving and we better cope with it or we'll be outdated
    Zach Rachedi
    @Shisuki

    Hey there, I'm using pnp/nodejs-commonjs with Azure Functions to add list items using a sharepoint Add-in, but I'm a bit stuck on how to catch exceptions because neither pnp-sp nor Microsoft's sharepoint REST API documentations are helpful here, or I haven't been searching very well

    I came up with a hacky way on how to get 400 error messages :

     async create(listTitle: string, properties: object): Promise<IItemAddResult> {
        try {
          const item = await sp.web.lists
            .getByTitle(listTitle)
            .items.add(properties);
    
          return item;
        } catch (error) {
          const message = this.getErrorMessage(error);
          throw new Error(message);
        }
      }
    
     private getErrorMessage(error: any): string {
        const mixedJson = error.message;
        const index = mixedJson.indexOf('{');
        return JSON.parse(mixedJson.substring(index))['odata.error'].message.value;
      }
    I'd like to get rid of the getErrorMessage method and use something more generic if I can
    Zach Rachedi
    @Shisuki

    The error object itself returns this

    {
      "response": {
        "size": 0,
        "timeout": 0
      },
      "status": 400,
      "statusText": "Bad Request",
      "isHttpRequestError": true
    }

    and error.message returns this

    Error making HttpClient request in queryable [400] Bad Request ::> {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The property 'Name' does not exist on type 'SP.Data.MattersListItem'. Make sure to only use property names that are defined by the type."}}}
    Anuj Kumar Pal
    @Anujkmrpal
    @koltyakov Hi I need some help in sppull, When i am using camlCondition and metadata then spRootFolder is not working it downloads file from other folders with metadata
    image.png
    image.png
    Anuj Kumar Pal
    @Anujkmrpal
    I set spRootFolder folder to Document/Output but I get file from Document/Input
    Andrew Koltyakov
    @koltyakov
    Hi @Anujkmrpal,
    Actually this by design. spRootFolder is not used in the mode with metadata filtering. But I see the logic in your case. Please check v2.6.3, the version update should include postfilter conditions after CAML is applied, so only documents located in spRootFolder, if the one provided, are downloaded.
    Anuj Kumar Pal
    @Anujkmrpal
    @koltyakov thanks
    shoaib0077
    @shoaib0077
    Hello, I would need to fill up a javascript object with all the site pages and their author information from sharepoint using pnpjs and then will set state in componentDidMount. I would need to use a for statement to get the author for each page in result and this is where i am not sure how to use promise and how to set state. Any guidance would be highly appreciated. I am using react. Thanks
    This is the kind of data i am trying to retrieve, the issue is if i use promise to get authors in for loop, state gets set with limited items and gets stuck until page is re-render.
    image.png
    Andrew Koltyakov
    @koltyakov

    You can easily get all that information in one call. Site Pages is a document library, similar as a list, all items can be requested with the metadata, author is one of the columns.

    E.g.

    const list = sp.web.lists.getByTitle('Site Pages');
    list.items
      .select('*,Author/Title,OData__AuthorByline/Title')
      .expand('OData__AuthorByline,Author')
      .get()
      .then(console.log);
    shoaib0077
    @shoaib0077
    @koltyakov Thank you very much, however, i am trying to retrieve Email by expanding Author/Email but its not working. As i would need email to get the user profile pic from user photo page "/_layouts/15/UserPhoto.aspx?size=s&accountname=
    Andrew Koltyakov
    @koltyakov
    @shoaib0077
    You can also get EMail as well, the common mistake is the casing, should be EMail but not Email
    image.png
    shoaib0077
    @shoaib0077
    That's Awesome EMail worked :) Thanks so much for saving me lots of calls.
    Andrew Koltyakov
    @koltyakov
    The greener the planet and MS spends less electricity =)
    Anuj Kumar Pal
    @Anujkmrpal
    @koltyakov Can we push files in sharepoint with sppull
    Anuj Kumar Pal
    @Anujkmrpal
    @s-KaiNet I am using spsave to upload file to sharepoint, file is uploaded but I also want to insert value in other columns
    image.png
    In above example i want to enter data in policyNumber but it is not inserted
    And can you please describe use of keys in filesMetaData
    above-average-developer
    @above-average-developer

    Good day, @s-KaiNet . I have been using sp-request to scrape pages within a site collections on SP2013 for a couple years now. I now need to update my node code to work with SPO, app-only permissions. I'm able to authenticate to SPO without issue however, the same technique to grab the HTML of a SP page no longer works.

    With SP2013, I could simply pass the full URL and the response would return the HTML. When I try the same with SPO I get an authentication error. Here's the current code:

    /*jshint esversion: 6 */
    
    const sprequest = require('sp-request');
    
    let spr = sprequest.create({
      siteUrl: 'https://tenant.org/sites/dev',
      clientId: '1beab0a4-a10d-4a6b-xxxx-b4c247faa95f',
      clientSecret: 'SZvu9Gmbxxxx9fHGeZ+KC9QBxxxx1ApHAlLeNAermug='
    });
    
    const url = encodeURI('https://tenant.org/sites/dev');
    
    function peek(url) {
      url = url.toLowerCase();
      return new Promise(function () {
        spr(url)
          .then(function (response) {
    
            console.log(response.body);
          })
          .catch(function (err) {
            console.log('Something went wrong.... ' + err);
          });
      });
    }
    
    peek(url);
    Sergei Sergeev
    @s-KaiNet
    @above-average-developer that's because spo uses different authentication. You could try username/password instead of app-only
    above-average-developer
    @above-average-developer
    I can authenticate with no issue and I can retrieve lists and libraries. I just can get the page HTML for scraping like I could in SP2013.
    • can't
    Andrew Koltyakov
    @koltyakov
    Add-in Only auth is limited with API consumption only, you can't use it for requesting a page content.
    above-average-developer
    @above-average-developer
    @koltyakov , that's exactly what I needed to know. Thank you!
    shoaib0077
    @shoaib0077
    Hello, I am having some issue with types i think. I am trying to set the style of an html element through reactdom and i know it should work but givng me the following error
    image.png
    Alex Lee
    @alexleely
    Hi hi, I am current using SPPP to create a react app on SharePoint 2016 on premise. The SharePoint site is on HTTPS. Can I check is it possible that the react app can be served thru HTTP2 protocol or it is a SharePoint Limitation due to Windows authentication that on application on Sharepoint is defintiely on HTTP1.1? Sorry if my question may be incorrect. Thanks in advance .