Thursday, December 2, 2021

SharePoint Online: Temporary fix for error The user or administrator has not consented to use the application with ID named 'PnP Management Shell'

 Hello All,


You will be shocked to see the error The user or administrator has not consented to use the application with ID named 'PnP Management Shell'  after using Connect-PnPOnline cmdlet for SharePoint Online.

There is a temporary solution. 

Solution: Downgrade your PnP module to version 3.20.2004.0

Here's what happened to me.

I got new laptop and setting up my Dev environment. 

- Installed PnP module (latest version)

- Tried connecting SharePoint Online using Connect-PnPOnline

- Got the error The user or administrator has not consented to use the application with ID named 'PnP Management Shell'

- Official solution is to ask admin to approve "PnP Management Shell" app

Seriously !!! Come on. 

As a SharePoint developer, I dont want to request Admins for these things.

PnP was very powerful tool for developers but now ?

Few experts were providing the solution to use Connect-PnPOnline -Url <siteurl> -Interactive . It didn't help.

On the PnP github, someone said that he downgraded the PnP version. 

I tried and it worked. 

Temporary solution

UnInstall-Module -Name "PnP.PowerShell"

Install-Module -Name SharePointPnPPowerShellOnline -RequiredVersion 3.20.2004.0

Sharing is caring. 


Tuesday, March 5, 2019

Tuesday, February 5, 2019

BEWARE - SharePoint Online Implicit managed property issue

If you do not want to read the whole story then here is the issue;
Implicit Managed Properties are CASE-SENSITIVE. Make sure you copy and paste the property name in your code. I was using it in Search's REST api and it was not working because I used "deptOWSCHCS" instead of "DeptOWSCHCS" (notice the first letter).

What is Implicit Managed Property?
SharePoint automatically creates a managed property when we create a column. Ex: If you create a site column called Dept with Choice type then SharePoint creates a managed property in the name of "DeptOWSCHCS".
DeptOWSCHCS is called Implicit managed property.

Let's dive into the purpose of this post.

User came to me and asked for a SharePoint page that should display items with the department name. Yes, I have already created the site column "Dept". [This is at high level]

I developed a solution using jQuery + Search REST api.
[You may think why did I choose this method instead of going with CSWP. Well, User gave complex requirement. I just mentioned at high level here for easier understanding.]

On the Search's REST api, there is a property called "selectproperties". Think of something like view fields in CAML query. I mentioned Implicit managed property "deptOWSCHCS". It was working fine for ~8 months.

Suddenly the values of the property (deptOWSCHCS) started returning null values for all the items. Since it is in SharePoint Online, I created a Microsoft support ticket. After many escalations, engineer from Fast search team contacted me. We did lots of troubleshooting.

I dont know what made me to copy and paste the property on the code. [Maybe I was frustrated badly.] It started working. WooHoo........ I found that there is a small letter "d" instead of capital letter "D" in property name DeptOWSCHCS. I asked the engineer. The engineer said, Implicit properties are case-sensitive. I was like WHAAAAAAAAAT!!!!! How come it was working for more than 8 months?

I asked for the documentation on it. Engineer gave me this link where I could not find that information. And engineer responded that it is something like internal information, blah blah.

I understood that the engineer is trying to cover Microsoft's mistake.
My assumption is Microsoft would have pushed some feature that would have caused this issue where no one identified. As a single person, I cannot make Microsoft to rollback the changes. Instead I have changed my code with case-sensitive names.

I have opened an issue on that documentation requesting them to add this information. Therefore developers need not to bang their head on investigating the issue. Because most of the developers do not follow case-sensitive on managed properties.

At the time of writing this post, Microsoft has acknowledged and they would be updating the documentation soon.

My question is; how could they make a change like this without notifying users? It was working fine for ~8 months.

Hope this information is helpful to you.

Sharing is caring !!!!!

Github Issue: https://github.com/MicrosoftDocs/OfficeDocs-SharePoint/issues/296

Monday, December 17, 2018

SharePoint Online: How to add multiple class names to SPFx web part

If you had override the CSS using Content editor web part on Classic experience then you would have faced big problem in SPFx.

Yes, you cannot override the CSS design because CSS preprocessor adds some random characters at the end dynamically. So you cannot override.
You might think why do I need to provide design customization for users in SPFx.

Here is my requirement:
I want to build a web part that displays restricted port numbers in table format. It will have regular table structure with header and body. Something like below.

Restricted Ports
80
12345
Site owners can add this web part on their team site if they want. They might have different color themes applied. If they want to change the header's background to red then we cannot go and develop a web part for their team site. Instead we can provide a multi line text box on property pane and allow users to add their design customization. (Note: You will have to add )

Believe me, my users are very technical and they know how to play with CSS designs. 

Here's how to add multiple class names; 
<div className={[styles.panelStyle,'customclass'].join(' ')}>

Earlier it was like this;
<div className={styles.panelStyle}>

Hope you find it useful.

Happy coding !!!!!

Wednesday, August 22, 2018

SharePoint Online: Content search web part is not displaying all refinable values

Have you ever be in this situation where you do not see all refinable values under mapped refinable property in CSWP?
You are not alone. :)

Here's what happened;
Business requirement:
- Want to display particular department items

Solution:
- Use CSWP and configure the refiners section.

Implementation:
- I have a created a custom column to hold department values
- Mapped this custom column to a refinablestring for using it on Content search web part (CSWP)
- I created a page with CSWP and configured it. I could not see all the values under that refinablestring.

You can follow this step to check on the refinablestring values.
- Create a page with Search web parts (Search box, search results, refinement)
- Configure the refinement web part and add the same refinablestring. You will be able to see all values.
This way you can confirm that the refinablestring has all values.

Below table represents my issue.
CSWPSearch Refinement WP


Why CSWP is behaving differently?
Those refiner values are being displayed based on the Search results preview items. Thus we see limited values.


What did I do to view required department value?
Please remember, this does not display all the values in CSWP refiner section.

- On Basics tab, change the path that has items with required column value.
Eg: I want to add "Legal" under Refiners tab in CSWP. I know there is a site(https://<sitecoll>/Legalsubsite) with an item with "Legal" value.
- Goto Refiners tab and look for the required value under refinablestring. (Notice that the search result preview will be refreshed)
- Then add that value
- Go back to Basics tab and change the path to original i.e., https://<sitecoll>
- Click Ok.

Basically, we are narrowing down the search results on preview to see our refinable values.

That's it !!!!!
Hope you find this content useful.