문제

Using below function:

const s = await sp.site.createModernTeamSite(
    CustomerName,
    CustomerID,
    true,
    1033,
    "Customer Site for " + CustomerName);

You can create a team Site, but how to get values from s?

In the console, I can see GroupId value. But from code, I am not able access to this.

도움이 되었습니까?

해결책

createModernTeamSite returns Promise<void> so you need get the value from callback function.

createModernTeamSite(displayName: string, alias: string, isPublic?: boolean, lcid?: number, description?: string, classification?: string, owners?: string[], hubSiteId?: string, siteDesignId?: string): Promise<void>;

sp.site.createModernTeamSite(
"LeeSPFxModernTeamA",
"LeeSPFxModernTeamA",
true,
1033,
"description")
.then((d:any) => {
    if(d.d){
      var groupId=d.d.CreateGroupEx.GroupId;
    }else{
      console.log(d);
    }
})

다른 팁

The createModernTeamSite function is async which returns Promise<void>. So, you need to await while it returns some value.

You can use your code like below:

import { sp } from "@pnp/sp";

sp.site.createModernTeamSite(
    CustomerName,
    CustomerID,
    true,
    1033,
    "Customer Site for " + CustomerName)
    .then(data => {
        console.log(data);
    });

When you will expand data in console, you will see all the information returned by createModernTeamSite().

You can follow below documentation to see the properties you can pass to createModernTeamSite().

official documentation: Create a modern team site.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top