Today I would like to write a few words how we can use App permission in SharePoint online. This topic is very interesting as also very useful. It allows us to make a lot of things with our tenant without direct login in Office 365 login page. Do you remember my post about geolocation? When you take a look on the code you will see that I used user name and password with clear text. Of course it could be fine in some situation, but in general we should avoid this. So the question is what we can do? How to remove user name and password from our application?

[adblockingdetector id=”5770e6ed85560″]
The best solution for this problem is to use App permission. With this approach our application will use tokens, which provide us much better security level. To do start we have to generate Client Id and Client Secret with following URL in our tenant:

URL: https://[tenant].sharepoint.com/_layouts/15/appregnew.aspx

app registration

Press Generate button. We will get two strings which will allow our application to authenticate with tokens. In Title field we enter name of our application.We should use something more than “my app” as in the future it could be difficult to remember purpose of the application. App domain should use localhost, and Redirect URI should have URL of our tenant. That’s the first step. After token generation we have to setup permission for our app. We can do this at following URL: /layouts/15/appinv.aspx. We enter following XML structure:

How to use it App permission in SharePoint online

So it’s time to use our knowledge in real world. Let’s create simple console application. Next in the NuGet Package Manager we should look for something called AppForSharePointWebToolkit. Install it.

AppForSharePointWebToolkit

After package installation we will get some references to Microsoft.SharePoint.Client.* and plik App.config, which is our next target. Let’s open it and add new section appSettings with our keys ClientId and ClientSecret. We put there our keys which we generate before. In our case it looks like this:

The last piece is new using statement in our code using Microsoft.SharePoint.Client; . And that’s all . In my cases I prefer to use additional class which has only one purpose – to return only clientContext for single URL, just like below:

A few months ago, Scott Hanselman announced, new solution which change mobile development for Microsoft world, and the others somehow too. That solution was called Microsft PowerApps. The solution wasn’t available for tests, it was just possible to register for preview waiting lists. Fortunately I work for the company which placed almost entire business in the cloud and Microsoft help us a lot with this. And thanks to my boss I was able to get early access to this coll tool. As far as I know right now PowerApps are available in preview for everyone, but I can see it in my App launcher. Well let see how it works.
[adblockingdetector id=”5770e6ed85560″]

Let’s start with PowerApps

To start go to your Office 365 tenant, press the app tile and run it. After that you will see the screen which looks like below:

PowerApps start screen

As you can see it looks simple. We also get four applications which Microsoft prepared for us to discover how PowerApps works. Let’s try to building something by our own.

I have very simple list in our Office 365 SharePoint online. This list is used for presenting some basic sales data. I just have there: Cashier name, net sales, clerk id and report day.

Those information are updated on daily basis by simple CSOM console application, which sends data from our ERP to SharePoint online. Press “New app” button. You will see pop up message “To create and edit apps, you need to install PowerApps Studio for Windows.” I have already installed it, so I have to just press “Open it”, and press “New” to start. You will see possible sources for our application.

PowerApps Start

And in my case choice is obvious, I mean I will use SharePoint online as source for my App. You will get textbox for url of your SharePoint site, enter credential and your will get all list in the site. Now just press “Connect” and our application make their magic. Please take a look at the print screen below:

PowerApps Screens

Without any additional work I get three screen, which has been created base on the data in my list:

Browse screen

Details screen

Edit screen

And in many cases it will absolutely enough for our needs, but if we want to build something more sophisticated you have a lot of options:

we can create additional screens

we can insert actions

we can create flow, really A LOT of flows, for example “Create Salesforce and Wunderlist Tasks” from the App

we can use icons, controls, forms, etc

we can add additional data sources

and much more

As you can see PowerApps were presented as simple solution for non developer people, but it’s looks very powerful. I think that in some cases mobile application can start worry about it… Let’s come back to our app. Now it’s time deploy our PowerApps to our organization. It’s very simple operation. You just need to “Save as” and then select option “the cloud”, and in next step you have just mark checkbox “Allow access to other users in my organization”. This option will save the app to your Office 365 tenant. After that when you open again PowerApps and login with your organization account you will see your app on the all available list apps. Also this one is available to you to edit.

Save PowerApps

Now let’s check if it works as expected. PowerApps solution can be used for example with iPhone, as well with Android devices. It’s time to login to App Store and install it. Now just login with your organization account and you can see on the all available apps in our organization tenant. As you can see my app is on the list… Awesome, isn’t it 🙂

Iphone PowerApps

Now you have just press the app icon and report is ready to go. As you can see entire solution is very simple, but it’s really powerful and it give to us a lot of options. I just find out that it has taken more time to me to write this post than create and deploy app itself.

401. That’s an error. Error: invalid_client

For one of my clients I have to build very simple website to host it in Azure. By the way Azure rocks! I love it and soon I will write at last a few post about it :). Anyway one of the requirement was that the site should have possibility to authenticate users, it shouldn’t be accessible to everyone. I’ve resided to use OAuth 2.0 provided by Google as it’s already pre configured for ASP.NET web sites. Process of configuration was very simple and very fast, without any errors but when I run my site I get message, Google API Error: invalid_client: 401. That’s an error. Error: invalid_client

Error: Invalid_Client

Strange, as Google Client ID and Google Client secret was correct. After some digging in I’ve discovered that to use OAuth from Google you have to fill also information on Consent screen. It’s not obvious as as error page from Google doesn’t indicate that something is missing on your developer consoler. Instead you get information that something is wrong with Client ID

Consent Screen

At last email address and Product Name must be filled. When you enter information at Consent screen and save your application will be able authenticate without any problem.
[adblockingdetector id=”5770e6ed85560″]

Is it possible to pass parameter in url to Infopath form?

Recently one of my clients had strange requirement to me, as they want to pass parameters in url to Infopath form. I done it before with asp, but never with InfoPath form. So let’s see what can can be done. When I start dig in it I’ve discovered that there’s no to many documents which described how pass parameter in url to Infopath form and if they exits they old . There’s also Microsoft site: How to: Use Query Parameters to Invoke Browser-Enabled InfoPath Forms, but it will not provide exact solution of our problem. And that’s all.

For my first test I just created simple InfoPath form with two text fields:

InfoPath form

It’s not too complicated. Now I would like to pass in url a parameter to field 1. In fact without writing a code there’s only one solution. We have to use InfoPath Form Web Part, and then we pass parameter to it. So how to do it? Let’s create simple SharePoint page and then place on it InfoPath Form Web Part.

InfoPath Form Web Part

No we need place where we store our parameter. To do this we will add Query String (URL) Filter to our page. We add Query String Parameter Name to out filter web part. In my case I just used Field1. Press apply, so now we can set up connection of our web part. To do this we simple going to connections -> send filter values to -> InfoPath Form Web Part.

Query String (URL) Filter

And here’s one tip. If you get error message during connection configuration:

The consumer Web Part did not provide schema information

You have to update your form. You have to go in your InfoPath to Option -> Advanced form options -> Property Promotion and there you have to add your column which will be accept parameter to “The fields listed below will be available as SharePoint Web Part connection parameters”. After that you have redeploy your form.

Web Part Connection Dialog

When SharePoint update our form we can go back to our page. Let’s go again to our Query String (URL) Filter web part. Now when we select again our connection the dialog should appear. I am going to select Field 1 as the consumer field name. We pressing save page button and now we can make a test. Now If I enter in the url window of my browser following string:

It will open my page with first field (field 1) filed with my name Tomasz. And as you saw this solution is simple at fast to pass parameter in url to Infopath form. Unfortunately we will have one big problem with solution. It’s not possible to provide in this way more than one parameter. And in some cases it’s not acceptable. What we can do I will show you in my next post.
[adblockingdetector id=”5770e6ed85560″]

Turn on Developer Site in Office 365

One of our task as SharePoint developers is SharePoint Apps development. It’s recommended approach by Microsoft, when we create solutions for Office 365 and to do this we need turn on Developer Site in Office 365. For this purpose Microsft provide to use Office 365 Developer Subscription, and there we can create site colection, base on “developer site collection” template. Sometime we have to work we standard site, but when we check SharePoint site settings there’s no feature to turn on Developer Site in Office 365. Of course it’s very easy to do this if we run SharePoint on premise, but in case of cloud enviroment it’s not so easy. Or rather I should wrote it wasn’t… A few days ago I was looking for solution of some problem and I discovered great project on CodePlex, called SharePoint Client Browser for SharePoint 2010 and 2013. After download we get browser of our site and after log on we can see all possible features:

SharePoint Client Browser

As you can we have all possible information in one place. And now something awesome. If you click with right mouse button on your site name, you will see option to run PowerShell with CSOM. That’s right!

PowerShell For Office 365

Let me say it’s so simple to run PowerShell against Office 365 site… And let go back to our developer site. When we start PowerShell consoler for the first time we will get couple of information about a few available parameters to use:

I’m working for my customer with SharePoint project. As there’ s nothing the part of the project is creating lists from scratch. As they weren’t too complicated I just save list template from my developer machine as stp file. Just a few seconds and the list was created on my client SharePoint farm. But when I display the list in some cases were issues. What’s happen? I’ve discovered that fields with issues where lookup fields. But why??? All list with lookup columns where already in place… Then I just learned that SharePoint use list GUID’s to link lists. So my field in list template is linked to column from my developer machine, by GUID, but my client SharePoint has a lists with different GUID’s and that’s the reason. So what to do?

1. Get your stp file and rename extension of the file from stp to cab.
2. Then you should be extract Manifast.xml file.
3. Replace the old value List Id in Lookup field with list GUID from the destination site

4. Save the file

5. Create cab file with Visual Studio with your xml file

6. When cab file is created rename it again into stp file

7. Upload to destination site and it works now
[adblockingdetector id=”5770e6ed85560″]

Application pages, part 2

Finally I was able to finish second part of post about SharePoint 2010 application pages. At the end of previous post you saw that for new item we need page for it. In my case it’s “WorkFlow01_New.aspx”. Of course we can imagine that the same form will be used for all tasks, but it could be to complicated and messy. Anyway we add new application page to the project and then we place into “PlaceHolderMain” module following controls : 5 labels, 4 text fields, 1 calendar control and button. The tricky part is that we don’t have access to graphic designer of VSTO, so we can’t see our design of the page in the fly. See below my simple page. As you can see there’s nothing fancy.

Now it’s time to create method to send data to the list. When you use application page all behaviours depends on you, so without that the button will be useless. As you see in the code of the page, I put already OnClick method into button control. The method code is below:

Ok, so what we do? The first part of the code create instance of our list. Then we assign values of our controls to proper columns of the list. And after that we finally call Update() method to put data on the list. At the end we have to remove application page from the screen. Also this last part of the code refresh content of our list.

And that’s all. I’ll try to create next part of the post and present how we can place there additional functionality.

I was very exiting that Microsoft released Express edition of TFS. For small development team it’s a great tool, which can be very useful. The interface looks like new metro application and it seems that new products will follow this path.

Unfortunately there’s a bug or maybe Microsoft business decision. You’re able to connect from Visual Studio 2010 to TFS 2012. But when you try to create new project you get an error like below:

which is crazy as I’m logged in as domain administrator and for example I am able to manage TFS security from Visual Studio level…
[adblockingdetector id=”5770e6ed85560″]

Do you remember my post about problems with BreakRoleInheritance in SharePoint 2007 (here)? There were errors messages that I didn’t dispose SPSite and SPWeb objects after usage. Partially I was able to solve it with some changes in my code, but there’re still entries in log files. For my next project I use SharePoint 2010, without any patches. I use again this code without any direct Dispose method, just put my code into “USING” statement and It works. There’s no any log information about problems with memory leaks during executing such code. Amazing