Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 26 2020 12:51
    anna-talley unassigned #59
  • Jun 18 2019 13:42
    patrick-rodgers closed #830
  • Jun 18 2019 13:42
    patrick-rodgers opened #830
  • Jul 10 2018 12:58
    patrick-rodgers closed #751
  • Jul 10 2018 12:58
    patrick-rodgers closed #753
  • Jul 10 2018 12:58
    patrick-rodgers closed #758
  • Jul 10 2018 12:57
    patrick-rodgers closed #815
  • Jul 10 2018 12:57
    patrick-rodgers closed #823
  • Jul 10 2018 12:57
    patrick-rodgers closed #824
  • Jul 10 2018 12:57
    patrick-rodgers closed #825
  • Jul 10 2018 12:57
    patrick-rodgers closed #829
  • Jul 10 2018 12:57
    patrick-rodgers commented #829
  • Jul 10 2018 11:06
    Mike-tech opened #829
  • Jul 06 2018 18:26
    koltyakov labeled #828
  • Jul 06 2018 18:21
    ken-harris commented #828
  • Jul 06 2018 18:21
    ken-harris closed #828
  • Jul 06 2018 17:51
    koltyakov labeled #828
  • Jul 06 2018 17:51
    koltyakov commented #828
  • Jul 06 2018 14:23
    ken-harris opened #828
  • Jul 06 2018 13:18
    koltyakov labeled #827
onur-saf
@onur-saf
I'm using sp-rest-proxy in local development but i got this error
Eirik Brandtzæg
@eirikb
Ok, I'm not very familiar with that. The author @koltyakov is active here so he might know better.
How do you plan to deploy this? I just use MSAL (@azure/msal-browser)
onur-saf
@onur-saf
I created page layout that type publishing page and i changed the the content like <div id="root" /> which my react bundle refers in dom. Everything is okey in production, my requests success. but in development mode fails.
Eirik Brandtzæg
@eirikb
Because you don't have cookies (or auth token) locally.
The proxy thing is probably a solution. MSAL is another. If you are going to run directly in SharePoint then proxy is probably best.
Another option for you, a simple one, is to create a new page and point to your scripts on localhost
Andrew Koltyakov
@koltyakov
Hey @onur-saf you can take a look at generator-sppp. It scaffolds none spfx projects with react, pnpjs and proxy ootb. However, I didn’t update PnPjs dependency to the recent yet. Yet, using recent PnPjs is just easy as bump the dependency, remove it from webpack externals and import PnPjs due to the v2 partial import guidelines.
@onur-saf on your err screen you have conditional access lock error. You can’t workaround it rather than reaching your admins to provide you an allowed route. It can be addin only auth, user app password and allowence in cas for your user. Or none proxy but aad app reg and openidc driven client side auth.
as @eirikb mentioned
While in SPO, why you aren’t considering SPFx native approaches?
onur-saf
@onur-saf
hey @koltyakov i'll take a look about generator-sppp thanks :) and for your question i don't have permission to upload webparts in my organization
Eirik Brandtzæg
@eirikb
@onur-saf Have you tried doing what I said? Create a new page like your old one, a page layout, and point to your localhost JavaScript
onur-saf
@onur-saf
@eirikb yeap sorry for late response I'm doing like you said now it's solved my problem for now. Just i couldn't hot update automaticly sp page when i've changed my code locally :)
@eirikb thank you :)
Ochuwa
@ObomighieSophie_twitter
Good day, how do I make the submit button on a custom sharepoint form webpart built with react and spfx post data to an existing list on sharepoint
also how do I make 1 list work on multiple sites but only display some particular columns on each page
onur-saf
@onur-saf
image.png
Hello everyone again, I need a help about WebPartZone. I couldn't found any article or something helpfull. I need to render a WebPartZone in my reactjs application it's not SPFX Project. is it possible ?
Andrew Koltyakov
@koltyakov
Hey Onur! No, it’s not possible. WebPartZone is the server-side driven. You can render react app in a webpart zone, but can’t render webpart zone with a client side.
Ryan
@Doogibo_gitlab
Question for the gurus. I have a scenario where none of the options seem to fit perfectly. We have a .NET Web API hosted in Azure and need to use SharePoint for document management (custom web front-end also involved). Our tenant is large, and we are not allowed to use App permissions (which grant full control to all sites in tenant), we cannot use on-behalf-of flow, because one requirement is management of SP User Groups which again requires admin consent to a permission that is too broad ... is creating a user account and signing into SP directly from our Web API the only option? I don't see this scenario talked about often, and PnPCore, etc. require you to go the Azure App Registration route ... any other ideas? Thanks!
Ryan
@Doogibo_gitlab
It seems so bizarre that App Registration scopes do not provide more granularity. There are tens of thousands of SP Sites in our tenant, we cannot safely consent to the scope that gives Full Control over all sites (though this would make life easier) ... hopefully one day they let you specify a particular site/site collection.
Ryan
@Doogibo_gitlab

https://www.leonarmston.com/2021/03/testing-out-the-new-microsoft-graph-sharepoint-specific-site-collection-app-permissions-with-pnp-powershell/

Just found that. Wow! Still requires admin consent... but seems like I'll have an easier time getting that granted.

matrixgoh
@matrixgoh
Hi i want to ask something, we have a powerfull pnp.js for customization, is any one here have a method to customize the edit properites form for Document/List library in the modern view?
Ole Bergtun
@trillian74
Quick ?: ChangeTokenStart in IChangeQuery in js - what kinda of date format is required here? i kinda want to check changes the last 7 days in a list. But i keep getting an overflow error in response: Error: Error making HttpClient request in queryable [500] Internal Server Error ::> {"odata.error":{"code":"-1, System.Data.SqlTypes.SqlTypeException","message":{"lang":"en-US","value":"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}}}
Andrew Koltyakov
@koltyakov
@trillian74 copying your comment with solution https://github.com/pnp/pnpjs/issues/2125#issuecomment-1050732361 , thanks for finding.
MahaVishnu
@devvishnu02
Hi, Pnp js query retrieves lookup/User id with lookup/Email value only while using expand query.
There are more then 20 lookups/Users fields. Pnp expand query cannot be performed due to dynamic approach.
Is there a approach where i can retrieve lookup/user id with lookup/Email values with email, without using expand query.
Andrew Koltyakov
@koltyakov
No, unfortunately you can't do it without expand in OData. However, you can use renderListDataAsStream instead. It returns emails for user lookups. Another alternative, which only would work for small teams, is to fetch all users (if a number is not large) and join responses on a client side. I'd recommend renderListDataAsStream way.
MahaVishnu
@devvishnu02
Hi @koltyakov Thanks for your Quick reply. But while using renderListDataAsStream. its not retriving all the lookup fields. some fields might get not showed in result. here also i cant able to give viewfields due to thresold limit.
let getDataById = await sp.web.lists
.getByTitle("TestList")
.renderListDataAsStream({
ViewXml: <View> <Query> <Where> <Eq> <FieldRef Name="ID"/> <Value Type="Number">${id}</Value> </Eq> </Where> </Query> <RowLimit Paged="TRUE">1</RowLimit> </View>,
})
MahaVishnu
@devvishnu02
@koltyakov is it good to use fieldValuesAsHTML ?. it retriving all the data that i want. but lookup and user is on html syntax. Which may be i can try to parse and get the value. But i dont know its the correct way.
await sp.web.lists
.getByTitle("TestList")
.items.getById(4).fieldValuesAsHTML()
Andrew Koltyakov
@koltyakov
I can’t say nothing bad about this method, especially while used as a workaround for something which otherwise could be done elegant. However, maintenance of such code obviously could be a bit more time-consuming.
MahaVishnu
@devvishnu02
@koltyakov thanks.
MahaVishnu
@devvishnu02
Hi, is there is any way to get AD Group members Count by using Pnp js graph. or any other way
await graph.groups
.getById("0000000-0000-0000-0000-00000000000")
.members.count() I have also tried this but its returning whole user member.
@koltyakov
Ryan
@Doogibo_gitlab
Is there an easy way to determine how close any given list/library is to the 5000 unique permission scope limit? Would it just be a matter of getting and counting the roleAssignments on each securable within the list/library and then calculating the number of unique principles?
Or am I thinking about it wrong? If I have a library with 4000 folders, each with broken inheritance. Am I at 4000/5000 regardless of what unique permissions those folders have?
Andrew Koltyakov
@koltyakov
image.png

Hi Ryan,

Unique break inheritance limit is a "bit larger" than 5000. Just for the info.
It's possible to relatively quickly (in terms of scheduled task) to iterate list items checking HasUniqueRoleAssignments property.

Ryan
@Doogibo_gitlab
This is fantastic information @koltyakov ! Thank you so much. By larger than 5000, you mean you can technically go over it, it is just not a best practice due to what the MS Docs refer to as "degraded performance"? Thanks again!
thinkdaniel
@thinkdaniel

Is there any way to know whether a role assignment was completed successfully e.g.

const result = await item.roleAssignments.add(Id, roleDefId);

This function does not return anything. So I do not know if the assignment was successful.

Eirik Brandtzæg
@eirikb
Hi. Jumping in on some Azure dev for the first time in ages - what is the current best/correct way to interact with Microsoft Graph in JavaScript?
thinkdaniel
@thinkdaniel
is it possible to assign permissions using a user's email instead of an Id?
 await item.roleAssignments.add(Id, roleDefId);
Daniel Watford
@danwatford
To create a graph client I create a TokenCredential based on config (populated from environment):
/** 
 Retrieve the credential for accessing M365 services such as Graph and SharePoint.
 We are using a ClientCertificateCredential since the function is likely running in different tenant to where
 the M365 resources are located. We are avoiding using the standard environment variables that would
 populate the {@link EnvironmentCredential} (as called from {@link DefaultAzureCredential}) as this should 
 allow us to use {@link ManagedIdentityCredential} when accessing other Azure resources.
 */
export const getM365AppCredential = (): TokenCredential => {
  return new ClientCertificateCredential(
    config.m365TenantId,
    config.m365ClientId,
    { certificate: config.m365ClientCerticate }
  );
};
Then the client is created with a bit of basic caching based on access token expiry times:
let cachedClient: Client = null;
let cachedClientExpiryTime: DateTime = DateTime.now().minus({ days: 1 });

export const getGraphClient = async () => {
  const now = DateTime.now();

  if (cachedClient && cachedClientExpiryTime > now) {
    return cachedClient;
  }

  let accessTokenExpiryTimestamp = 0;

  const credential = getM365AppCredential();
  const client = Client.init({
    authProvider: (done: AuthProviderCallback) => {
      credential
        .getToken("https://graph.microsoft.com/.default")
        .then((accessToken) => {
          accessTokenExpiryTimestamp = accessToken.expiresOnTimestamp;
          done(null, accessToken.token);
        })
        .catch((err) => done(err, null));
    },
  });

  cachedClient = client;
  cachedClientExpiryTime = DateTime.fromMillis(accessTokenExpiryTimestamp);

  return cachedClient;
};
Eirik Brandtzæg
@eirikb
@danwatford Thanks for the answer. I ended up using pnp, but I see now I should have used the library you used instead.
For token I just used @azure/identity with Managed Identity, so no Ids/secrets/keys etc.
Daniel Watford
@danwatford
@eirikb - That makes sense to use pnp, we are on a pnp chat forum after all! I honestly can't remember why I didn't use pnp myself in this particular case other than there was some sort of issue which I couldn't resolve at the time.
Ryan
@Doogibo_gitlab
Not sure if anyone else has experienced this before but whenever I create a lookup field via REST it works/looks fine, until I actually try to add a value to it. The request succeeds, but the value never gets added. Can't add a value to the lookup field via REST or SPO form interface. Manually deleting the field and re-adding it via the List Settings fixed it. Here is how I'm adding the field:
await getSP()
  .web.lists.getByTitle("G")
  .fields.addLookup("m", {
    LookupListId: "355f8f10-4ae3-4bf2-b112-544c766562e0",
    LookupFieldName: "Id",
  })
  .then((f) => f.field.update({ Indexed: true }, "SP.FieldLookup"));
Ryan
@Doogibo_gitlab
Aaand I think I figured it out: LookupFieldName: should be "ID" not "Id".
Ryan
@Doogibo_gitlab

Apologies, just trying to wrap my head around this. The above solution resolved it for the most part, but I'm running into another issue now having to do with caching.

Currently I am doing a lot of: adding lists, deleting lists.. until I get everything correct. Part of adding the lookup fields is supplying the LookupListId. To get this I make a request to get the list, selecting the Id... however I am getting a lot of 304 Not Modified responses with the incorrect list Id value (it returns the previous list id value, prior to deletion/recreation).

Of course, if I start up a new session everything works fine, but I would like to figure out why this occurs. Thanks in advance!