Tuesday, 27 August 2019

Implement RenderComplete in React SPFx Webpart

Issue -

One of our Modern SharePoint Project HomePage was taking a long time to load. We raise a ticket to Microsoft for same. To Identify the actual loading time of our web parts, Microsoft asks us to implement RenderComplete function in our custom web parts.


Analysis -

The main issue about the function implementation is it is not documented anywhere in any posts. So it was always trying and error situation. So if you are in the same situation, use below code reference to solve the issue.


Code Solution - To implement the functionality, open your code solution and in your web part, follow the below steps:


  • Open your interface file. add below property to it
    asynccompfunc:() => void;

  • Now open your web part.
  • In your web part ts file, add below code in "render" method.

    public render(): void {
      const element: React.ReactElement<ISubmitNewsProps> = React.createElement(      SubmitNews,
          {
           // other properties...,
            asynccompfunc:this.renderCompleted
          }
        );

        ReactDom.render(element, this.domElement); 
     }
      protected renderCompleted(): void {
        super.renderCompleted();
      }

      protected get isRenderAsync(): boolean {
        return true;
      }


  • Now open your web part tsx file and add below code in "componenetDidMouth" method.

    // Init Function of component mount
      public async componentDidMount() {
        //your code to get data
        this.props.asynccompfunc();
      }

once these changes are applied in your webpats, deploy package. Once your build is deployed, open the page where you have added you web part. Click "Cntr + F12". it will show the performance of your webpart in webpart tab.



Note: This method requires "BaseClientSideWebPart" class to be extended. Application customizer does not extend this class. So we cannot implement this method in Application Customizer.

If you have any questions you can reach out our SharePoint Consulting team here.

Sunday, 30 June 2019

SharePoint Online Allow custom scripts - Part 3

We have looked at why Microsoft disabled custom scripts in SharePoint Online and where it affects. We have looked in previous two blogs why and what is alternative. If you have not gone through that, please check below links.




In this post, we are going to review how to enable custom scripting on site collection level and what will be its impact.

So if we enable scripting at tenant level we may end up loosing control over security. Instead Microsoft Provided a way to enable scripting at site collection level.

Prerequisite:


  • SharePoint Online Management Shell 


Follow below steps to enable scripting at site collection level:

  • Open the SharePoint Online Management Shell console. 
  • Execute the command to connect the Office 365 :

    Connect-SPOService -Url https://tenant-admin.sharepoint.com
  • Execute the command bellow with the url for the site collection where you want to enable scripting:

    Set-SPOSite -Identity https://tenant.sharepoint.com/sites/contoso -DenyAddAndCustomizePages 0


Pros:


  • Tenant level scripting enable may take up to 24 hours. But this approach disable the scripting block immediately. 
  • As this settings are enabled at specific site collection, you can make sure the scripting do not affect other site collections or tenant.

Conclusion:

We have seen limitations and how to overcome that. If you need to enable scripting, choose the settings as per your need.

Saturday, 27 April 2019

SharePoint Online Allow custom scripts - Part 2

We have looked at why Microsoft disabled custom scripts in SharePoint Online and where it affects. If you have not gone through that, please click here to read it.
In this post, we are going to review how to enable custom scripting on tenant level and what will be its impact.

Enable Scripting at the Site Collection Level 

Follow the below steps to “Enable” the custom script at the tenant level:
  • Login into your Office 365 Admin Portal.
    URL - https://admin.microsoft.com
    Click on ellipses in the left side panel.

    Note:  If you have Office 365 Germany, sign in at https://portal.office.de. If you have Office 365 operated by 21Vianet (China), sign in at https://login.partner.microsoftonline.cn/. Then select the Admin tile to open the admin center.
  • Then, it will display all the menu option in the panel. Scroll down and hover on "Admin" center menu and click on "SharePoint" as shown below image.
  • It will open the SharePoint admin page. In the left navigation, select 'Settings'.
  • It will navigate to the settings page. Scroll down till "Custom Script" section. In this select "Allow users to run a custom script on personal sites" & "Allow users to run a custom script on self-service created sites" as shown in below image:
  • Then scroll down to the end of the page and click “OK”. It will take about 24 hours for the changes to take effect.
 
Once these settings are implemented, you will have your classic SharePoint available same as you know. But this also enables the threat that we discussed in the first part. So we would not recommend this approach. 
So what is the alternative? Check out our last post of this topic for same. 

 Reference Link

The "Mark as Decorative" Feature in SharePoint: A Small Toggle With a Big Accessibility Impact

If you've spent any time building pages in SharePoint Online, you've probably noticed a new checkbox tucked inside the Accessibility...