Fabian Williams SharePoint Blog

Solving problems with SharePoint day and night

ACTUALLY RESOLVED: Unable to Create List using SharePoint 2013 REST API in SPD2013

Are you ready for this?

Im never satisfied with the answer “No you cant do that”, not as a Developer :-) So, i began to read through some TechNet and MSDN articles for Workflow and found this Gem. http://msdn.microsoft.com/en-us/library/jj822159.aspx 

What this Gem does is EXACTLY what Chris Givens found out and did in his PowerShell but as we discussed in my “Resolved post”, we cant run those scripts inside Office 365 SharePoint Online. So, it seems that you have to activate a Site Feature in your Site that you need this “elevated permission” then you need to copy the App Principal ID from the one you want elevated then take that to a “hidden” link inside the App Catalog Site http://{hostname}/{catalog site}/_layouts/15/appinv.aspx and then work your magic to elevate the permissions via an XML node copy / paste magic.

Anyway the GOOD NEWS is that I have tested this in SharePoint Online, and it works like a champ, see below for screenshots.

If you would like the full history of this, see the following post in chronology

  1. https://fabiangwilliams.wordpress.com/2013/09/06/help-unable-to-create-list-using-sharepoint-2013-rest-api-in-spd2013/
  2. https://fabiangwilliams.wordpress.com/2013/09/07/resolved-unable-to-create-list-using-sharepoint-2013-rest-api-in-spd2013/

Proving it out

First me activating the Feature

image

Next grabbing the App Principal ID needed for the Workflow in question. Now i purposely cut off all of the ID, i dont want some crafty person out there using it. Just realize that this is the same account that Chris and I talked about in the PowerShell

image

then moving the piece of Workflow logic that does the List Creation inside the App Step inside SharePoint Designer

image

and finally re-running the Workflow will yield the below in the Workflow History

image

and just to bring it home, here is the new List or (App i guess) Created

image

 

Cheers FGW

September 8, 2013 Posted by | Azure, JSON, Office 365, SharePoint 2013, SharePoint 2013 Workflows, SharePoint Designer 2013, SharePoint How-To, Strange Stuff | 13 Comments

Error/Resolution: Could not load type ‘System.Data.Services.Providers.IDataServiceUpdateProvider’ from…

Synopsis: 

Cryptic message huh, but basically i got a tweet from @dfollette regarding using the Client Site Object Model (CSOM) in SharePoint to gain access to List Data and other LOB System and he also had a reference in a Web Cast to do the same thing using the REST API.  Even as tired as i was at 1:16 am in the morning it would just eat at me in bed, so i decided to review it before I tuck in.  However, when I tried to review the REST API by using a SharePoint Web Service I got an error…

The tweet was:

image

The Error was:

image

 

Resolution

So after a little research I found this blog entry “REST and SharePoint 2010 Quick Start Guide: Table of Contents” on Scott Currier Blog; and it indicated that you need to install install the ADO.NET Data Services Update for .NET 3.5 SP1 Depending on what flavor OS you are running you may need one over the other, the one i need was here because I am running WIN 2 K8 R2 http://www.microsoft.com/downloads/details.aspx?familyid=79d7f6f8-d6e9-4b8c-8640-17f89452148e&displaylang=en

Once you install it you will be prompted to restart.

image 

 

Trust but Verify

So after my reboot, let us now go to my SharePoint Site Collection and query the REST API again.

What i wanted to test was a little nugget I learned from the web cast…

image

You know come to think of it, I should have done a snapshot before running that update, but oh well, with finger crossed…

image

and it worked, lets drill down now

image

Looking at the XML you see the actual data..

image

July 6, 2010 Posted by | SharePoint 2010, SharePoint 2010 RTM, SharePoint Bug, SharePoint Development, SharePoint Error/Resolution, Strange Stuff | Leave a comment

How To: Use SharePoint 2010 WebParts with a GridView Control to get SQL Image Data type and other Values

Recently I was faced with a challenge

  • Render a LOB System Data in SharePoint. Datatypes include an Image (BLOB) , char and int
  • Provide a means to filter by Last Name

Initial Approach

So as all professionals we should ‘Strive For’ the solution that can be done Out-Of-Box before trying to code a solution.  That said, I came up with a few ideas

  1. Use Business Connectivity Services (BCS)[yeah my one an only true SharePoint Love] to get this information, why, because it is in a LOB system and its SQL, and… well you get the drift: failing that
  2. Use a Visual WebPart in Microsoft Visual Studio 2010 arsenal of weapons, why, because I can just have the gridview auto create the columnd and be on my way: failing that
  3. Use a gridview control as part of a WebPart in Visual Studio 2010.. this is what won otherwise there would be a 4,5,etc….

The Gotchas

Well with the BCS approach; using SharePoint Designer 2010, we are not able to get the Image data type to come accross, much less map to an office property (a nice to have)

clip_image001

clip_image001[5]

Screen clipping taken: 6/29/2010 6:09 PM

clip_image002[6]

Screen clipping taken: 6/29/2010 6:20 PM

Now that we have put that to bed. Lets try some of our coded approaches.

    One approach that we could take would be to do a visual webpart with a gridview control on the page with "Auto-Generate Field" turned on; yeah, that was my first instinct too. However that will not work

    clip_image001[7]

    What will happen here is that the fields will in fact auto-generate however the only fields that will come across will be textual fields and of course our SQL Data Type is of type "Image". So in the end if you use exactly what we saw in our Business Connectivity Services example with SharePoint Designer 2010 visualized in an External List.

    Not to be dissuaded; my next thought was NOT to abandon the gridview control but to add a ‘Template Field’ and include an ‘Image Control’ inside with a reference to a HTTP Web Event Handler… sure this has to work, because I will explicitly stream the bytes in the Handler.ashx file and call it in the ImageUrl Property of the control….

    clip_image002[8]

    Yeah that wont work either because by the time the page [a User Control page ".ascx"], it is too far gone…. But a Visual Web Part would have made it sooooo eassyyyyy. But alas we have to look for another way.

    So your results will look like this….

    clip_image003

     

    The Solution

    Interestingly enough, the solution lies in all of the above with the exception that we cannot use a "User Control Page", we have to use an ".aspx" page. We will still have to use a HTTP Web Event Handler because we need to deal with the fact that we are pulling an Image directly from a SQL Database as a BLOB. So here are the steps I took

    Steps:

    1. Create an Empty SharePoint 2010 Visual Studio Project
    2. Add your Mapped SharePoint Folders for the _Layouts Directory as we are creating an Application Page. If you plan to add images too especially for your Feature, then go ahead and map the Images Folder also

    clip_image004

    1. Next in the same manner add an Elements Section
    2. When you are done, right click on your Folder within your mapped folder [coincidentally it will be the same name as your Project] and ‘Add a new Item’ which will be an application page.

    clip_image005

    1. I call mine "DisplayEmployeesWithPic.aspx" and this will create your page and your code-behind .cs file

    clip_image006

    1. So as it is an Application Page in our Visual Studio Template, it ready to go with the ContentPlaceHolders; we will be targetting the PlaceHolder for "Main" and wire-up our GridView and I am using a Button to add a filter.

    clip_image007

    1. We code against that in our code behind page to set our Datasource [which because I am a lazy developer, we will use the LINQ to SQL Data Connection], perform our query, data-bind and apply filter. You will notice below that I moved away from "Integrated Security" to "Standard Security" in my SQL Connection string because I met into two (2) specific problems (a) ‘Double Hop Problem’ when I ran the code from my Virtual Workstation and (b) Unless I had the End User to the LOB System, they didn’t have access to the dataset. I could have used Kerberos to solve my Double Hop issue, but I still would have the data access to deal with and I use that database to showcase my Business Connectivity Services / Secure Store [Single Sign-On] demos also, and how could I reasonably say that I am doing single sign on when I have folks there all willy nilly in the DB.

    clip_image008

    Screen clipping taken: 6/30/2010 7:42 PM

    1. The next thing we have to do because we are going after a non character data type in the SQL Database and trying to display it on a Grid View control is we need an HTTP Web Handler (a .ashx) file. This little code here is what intercepts traffic and steams the image to the image control previously seen in Step 5

    clip_image009

    1. Next we will add a Feature and ensure that the files are copied into the "Items in the Feature" section. The Elements .xml should auto configure it self also. You will notice I set the Scope to Site not the Default "Web".

    clip_image010

    Below are the options now in Visual Studio 2010 Teamplates

    clip_image011

    1. You Debug or Build and Deploy your Solution to the Farm. Yes, Farm, this cannot be done as a Sandbox Solution because it is touching the file system.

Trust but Verify Section

So that you can see that I have nothing up my sleeves [if you have ever sit in one of my Confrences or Speaking engagements, you know I always say and do this part] I will show you the results as is, then I will walk you through adding a recoredset and see the live results in SharePoint

  1. This is what we expect to see based on what is in the LOB System Now

clip_image001[9]

With a Filter

clip_image002[10]

Screen clipping taken: 6/30/2010 7:57 PM

  1. Next and in the spirit of the World Cup where Spain WILL / MUST WIN!!! (I now digress), we will add David Villa and the guy I so love to pick on; and yeah maybe it’s a little haterism, cry baby Ronaldo. Lets go get some stats…

clip_image003[5]

Screen clipping taken: 6/30/2010 8:00 PM (curtosy of Fifa.com) so I don’t get sued…

clip_image004[5]

Screen clipping taken: 6/30/2010 8:04 PM

clip_image005[5]

FIFA.com – 2010 FIFA World Cup™ – CRISTIANO RONALDO

http://www.fifa.com/worldcup/players/player=201200/index.html

Screen clipping taken: 6/30/2010 8:07 PM

clip_image006[5]

The Proof is in the pudding

clip_image007[5]

Hope this helps everyone who comes across it, as usual, your comments, critiques, and questions are welcomed.

June 30, 2010 Posted by | Business Connectivity Services, SharePoint 2010, SharePoint 2010 RTM, SharePoint Designer 2010, SharePoint How-To, SQL Server, Strange Stuff, Visual Studio 2010 | 5 Comments

Question: Not able to get Email Alerts when using an Email Enabled Windows Security Group in SharePoint 2007

I have a situation where I have an email enabled security group with individual users in it, this security group is added to a SharePoint group. Here are some known

  • I am using the Site Owner to Add Alerts on behalf of users
  • if you enter the email address a user into the "Send Alert To" field and click ‘check name’, it resolves to the User
  • if you enter the email address of the Security group into the "Send Alert To" field and click ‘check name’, it come back "No Matches Found", same if you go to the Browse Icon
  • If you try to create the alert anyway using the security group, it creates the alert but tells you that there is no email address associated with the security group
  • If  you just add the preferred name of the Security Group to the "Send Alerts To" field then it resolves; but it creates the alert but tells you that there is no email address associated with the security group

However

  1. I created a new Email Enabled Security Group and two Test users today
    1. Test user 2 is a member of the Email Security Group
    2. I am able to send emails to test user 1, test user 2, and the security group in Outlook
  2. I did a full import into SharePoint and they all show up WITH their associated Email Address in the Profile
  3. I added the Security Group [Add User] directly into the Site as a contributor
    1. Tried to setup an alert. you get what is in top bullet 3 and 4
  4. I added the Security Group to a SharePoint Group, then added the SharePoint Group to the Alerts; failed…

I pulled down a feature from CodePlex http://www.codeplex.com/AdvancedAlert and tried list number 4 above; failed, but if i added an Individual User to the SharePoint Group and did number 4, the individual user gets alerts

I saw this out there also.. tired it… failed http://blog.gavin-adams.com/2007/10/26/sending-alerts-to-groups-in-sharepoint-2007/

Thoughts?

RESOLUTION

I found out that the Web Application Pool along with a few other accounts are Local Accounts

 

So the test/fix

· I created a new Web Application and used a domain account they had out there as the Web App Pool account

· I NOW am able to resolve the Security Group Email address

· I NOW can receive the initial alert email

· Once I added the Security Group to a Permission Group in SharePoint for the site (View, Read, Contribute) directly

    • I can receive security trimmed email alerts

Next we document and use the KB article 934838 to change the accounts in production

Tuck this one away people…

March 11, 2010 Posted by | SharePoint Administration, SharePoint Error/Resolution, Strange Stuff | Leave a comment

How To: Create a Farm Based and Sandbox Based Solution Web Part using LINQ to SharePoint via SPMetal Utility

Synopsis

In this Blog and in all the blogs i post, I try to re-use my work/efforts; for one, it ensures that the information is grounded, it certainly gives me practice, and more importantly, it demonstrates how SharePoint is modular, and how each part of the Wheel Compliments each other.  So.. </soapbox> over, lets begin… The idea here is to demonstrate how we can affect changes to SharePoint Lists and Libraries; for instance, we will use LINQ to SharePoint to talk to Lists in a Site, and use Sandbox Solutions to "work in that list in a protected area” based on the Rules of the Sandbox.  Now; the intrusive part is the how we gain access to the SharePoint List, in this example (Part 1) I am still doing a Sandbox Solution which means it is limited to the Site Collection, but I still have code that may be better protected in a “Full Trust Proxy” which will be (Part 2).

Get ready on how you can do:

  1. Create a Sand Box Solution with Visual Studio 2010 Beta 2 on SharePoint 2010 Beta
  2. Use LINQ to SharePoint via the SPMetal Utility to create and add a Class to our Solution to act as the Wrapper to our Content Database
  3. Create a Web Part to display information from SharePoint Lists
  4. Use some Code to do some actions on that List

Recognition of Effort to my friends in the SharePoint Community

So… I want to take time out to recognize some of my buddies in the SharePoint Community that helped with a really weird issue I was having trying to get even a “Hello World” textbox control working in my Sandbox Solution.  As it turned out and I do have the troubleshooting steps outlined below, my issue was related to having SharePoint 2010 on a Domain Controller, and the problem was solved [albeit after 12 hours of work and 4 – 6 hours troubleshooting] via a PowerShell Script found on Jie Li’s and Jeremy Thake’s site.  Using Twitter (yes I know, I tweet too much) I solicited the help of my co-worker Bart Tubalinal @bart_tubalinal and Jeremy Thake @jthake to see if they saw something glaring wrong in my code; they looked, they found nothing… then i hear the words I didn’t want to hear “… have you tried looking in the ULS log…, this may be your environment…” this would have not shocked me as much if I didn’t have to deliver at Virginia Beach SharePoint Saturday this coming Saturday (1/9/2009), and didnt want to risk doing an re-install my OS. In the end Paul Swider @pswider asked if i ran the script found on Jie Li’s site; as soon as i placed it in a file and ran it with PowerShell, BOOM! I was good to go!  Mark Miller @EUSP of End User SharePoint pointed out that he may emphasize the community involvement in a Keynote he is prepared to give, I encourage him to do so.

Let us Begin…

 

Part 1: This is Part 1
Part 2: Doing everything but using a Full-Trust Proxy for the most Intrusive Part of the job!

So the first thing we need to do is crack open our spiffy Visual Studio 2010 and Create a new SharePoint Empty Project

clip_image001

  1. Fire up Visual Studio
  2. Select SharePoint 2010
  3. Select Empty SharePoint Project (as you can see I named mine TouchPeopleinSharePoint)

clip_image002

Next you will be prompted to choose if this is a Sandboxed Solution or a Farm Solution, I selected “the Default” which is SandBoxed Solution… so what is Microsoft trying to tell us here folks?

clip_image003

Once you have done that, click Finish to close out the dialog box.  Next just to be sure, you can never be too careful; since I am building against a x64 bit system, I wanted to make sure that my Project Properties Build Targets were appropriately set.

clip_image004

Once I have completed that process, next I am going to add a new Web Part. NB, you are not permitted to do Visual Web Parts in SandBoxed Solution because that would mean that you would need to deploy it on the WFE; which under SandBoxed Solutions, we don’t want to, so… we wanna select a regular web part.

clip_image005

See below…

clip_image006

So once the Web Part is added, we have the following cs file created, clearly you can see we have methods that are over-ridden which we will employ in our solution.

clip_image007

Before we get there however, I need to do some prep work..

  • I need to Add my SPMetal Class
  • I need to make a reference to Microsoft.SharePoint.Linq

This Class that I am adding is created by SPMetal Utility and it basically provides me Entity Classes and a Context Object to manipulate SharePoint Lists via LINQ to SharePoint. I use this because all that plumbing is already done for me and hey, work smarter not harder…

clip_image008

clip_image009

clip_image010

NB. The Red squigglies are there in this CharlieSiteLists.cs file because I dont at this time have a Reference Set for Microsoft.SharePoint.Linq which i will do below…

clip_image011

So now for the real work… finally!

  1. So first I create a List Box object, I will add my result set to that collection (line 16)
  2. I make a reference to the CharlieSiteList.cs (SPMetal Utility Created File) Data Context Object so I can use it as a Wrapper to the Content Database (line 25)
  3. I iterate though a list and return the First Name and Last Name via the Add Method of the ListBox Object (line 26 – 33)

clip_image012

That is it! Easy huh… now we just Deploy our Solution…

clip_image013

Next I go to my site under “Site Pages” and create a Web Part Page…but before I do that, lets just make sure that our Sandboxed Solution is there in the Gallery. We find this by clicking on Site Settings and under Galleries, you will see “Solution”.. go ahead and click that bad bwoy..

clip_image014

All being well you should see your solution as I see mine…

clip_image015

Now, we edit that page we would have created to hold our Web Part or you can just put it in a page of your choosing. 

clip_image016

So, here is where the SharePoint community came alive for me last night.. and although SharePoint threw no Error in the Event Viewer, nor did the Actions yielded any “gotchas” that I did anything wrong, when I added the Web Part to a zone..

When I add the TouchPeopleNOLookupList Web Part to the Left Column Zone as indicated below it goes though the motion but ADDs Nothing but in the ShowMyProfile Web Part it works… that web part is a Farm Level Solution though… same code.. 

clip_image017

Below Same Code… in the Create ChildControls in a NON SandBoxed Solution

clip_image018

U can see in the Properties Window that this one is same code but not SandBox Solution… and it yields results as above…

clip_image019

So as part of my debugging I downloaded this ULS viewer from CodePlex at http://ulsviewer.codeplex.com/ and I saw that, Indeed, I have a few errors going..

image

Paul Swider pointed me to Jie Li’s site where i saw below,

image

I placed that script in a file and ran it with PowerShell and I got my Web Part to work as indicated below. 

image

We are in business folks…

image

Stay tuned for Part 2 where I will do this all with a Full Trust Proxy i.e. move the intrusive Class that actually touches the Content Database to the GAC and use a Proxy to call it.

 

Have fun! 

January 4, 2010 Posted by | SharePoint Administration, SharePoint Bug, SharePoint Development, SharePoint Error/Resolution, SharePoint How-To, Strange Stuff, Visual Studio 2010 | , , , | 3 Comments

Cannot save a document or workbook to a Document Library, only to your My Documents Folder

Tested and Confirmed on the below Platform

  • Windows Server 2008 R2 x64

  • Microsoft Office SharePoint Server (MOSS) 2007 SP2

Synopsis

You have a document library and with our without Custom Site Columns, Content Types, just OOB, when you try to save a document; whether it is a Word Document, Excel Document, etc., you are unable to save to the document library nor can you even create a network shortcut to your site location.  You sometimes get “Path does not exist”.  This is by design….

Resolution

In Windows Server 2008 even R1 and certainly in R2 for x64 bit systems the WebDav protocol is built into the feature called “Desktop Experience” and you must turn it on.

image

September 11, 2009 Posted by | SharePoint Administration, SharePoint How-To, Strange Stuff, Windows Administration | | Leave a comment

How To: Strange but True – If you use a permanent marker on a White Board…a simple Fix to get it Off

Synopsis

So i would not believe it if I didn’t see it myself.  Here is what I did.  [Disclaimer] I wasn’t the one who put Permanent Marker and Dry Erase Marker in the same place. :-)

I am about to draw a line on the board to separate an are for “Parking Lot” information.  I took a permanent marker “unbeknownst to me” and drew a 1 meter line from top to bottom. Only after I hear the crys of OMG, that is a permanent marker did i stop… but alas too late.

 

FIX – “Credited to one of the Sessions Participants…”

  1. Take a Dry Erase Marker
  2. Use the Dry Erase marker and cover, really cover, the entry made by the Permanent Marker, be generous in your application but not over kill
  3. Use the Dry Eraser to erase your entry… Voila, the Dry Erase Marker and Permanent Marker entry are gone.
  4. It really works…
Maybe i can get the Sham-Wow Guy to market this for me…

August 18, 2009 Posted by | Strange Stuff | 1 Comment

   

Follow

Get every new post delivered to your Inbox.

Join 3,963 other followers