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
    So it’s SharePoint Online but still classic pages. Well, on the long run it’s better invest into learning SPFx (mostly just the ordinary front end dev with a couple of nuances) and Modern Sites. To switch to more robust SharePoint aware build system as a pre-spfx step I can suggest SPPP generator. It’s for classic SharePoint. We still use it with On-Prem projects.
    Zach Rachedi
    @Shisuki
    Thanks for the quick reply!
    As i said tho I'm still really new to Sharepoint, can I use the PPP generator to slowly refactor the existing website ?
    Andrew Koltyakov
    @koltyakov
    Yes, you can. One of its actions is just in case pulling existing assets from SP site. Though it’s a very old approach. And I’d better recommend never treating ./dist folder as something stored in git rather than a temporary folder for built assets only.
    Another approach is to grab some configs as an example.
    Zach Rachedi
    @Shisuki
    Thank you! I'll try following your Wiki and build something small with it and see. Can you point me to some ressources to learn that ? I want to create a few test pages on my local machine, have them use a few node libraries and have them share some custom modules all in Typescript and publish everything in SPO so I can show my coworkers some proof of concept before they let me mess around with a big refactor
    Also, we don't have a dev environment nor anything to test code with (I know.. I'm also looking for ways on how to set this up) so I'm gonna try all this on production code and I'm really afraid to mess things up
    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