|
Apr
14
|
Hi, today I will fully explain how to create a “custom action”. For it I will use “Visual studio” and WSPBuilder, you can find it on codeplex.
Our action will appear on the display page of all the items of a custom list. By clicking on it, the user will be redirected to google. A custom action has to be included in a feature, meaning, we will create a standard feature and add code in it to define that we want to create a custom action.
So now let’s get started, you will need to create a new WSPBuilder project (without workflow), when the new project is loaded, choose Add->WSPBuilder->Blank Feature. The system will ask you a name and to choose a scope, in my example the scope choosen is web (for website). If you have done a mistake about the name or the scope, that’ not a problem, you will be able to modify those directly in the XML files.
Now that you’ve created your new feature, you will have in the document explorer an hierarchy like the following picture.
Now you have all your structure done, here is the code to include.
The feature.xml file will contains all information about the feature (title, ID, scope,…), use the intellisense to check what is proposed. The important thing is the link to the manifest, in our case, “elements.xml”.
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="0FE81D03-6AE0-48a0-BBF7-88A1DAA9B04A"
Title="Import UP"
Description="Description for Import User Profiles"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
The elements.xml file define the content of the feature, in our case a custom action. To find the required fields refer to that MSDN link: CustomAction Element (Custom Action) . What is really interesting is the registrationtype, you can register to some different contents in our case the lists and the registrationID refers to the type of list (100=custom list) we want to add the action in. But you can choose a registration of type content type and give the name of it, so that action will be relevant only for that content type. An important thing is to define the location of the action, where it will appear. The URL define where the users will be redirected when clicking on it, it can be, and probably will be in the real life a custom ASPX page.
Refer to that MSDN link to find all the location and GroupID (in the comments too!): Default Custom Action Locations and IDs
You will see the 2 first columns, location and GroupID, if the GroupID is not empty or not contains N/A, you will have to include it in your custom action element, an example is done at the end of the post.
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="CustomActionGetUerProfiles.CustomAction"
Location="DisplayFormToolbar"
Title="Import Users"
RegistrationType="List"
RegistrationId="100"
Sequence="10"
Description="The description" RequireSiteAdministrator="FALSE">
<UrlAction Url="http://www.google.com"/>
</CustomAction>
</Elements>
Now that you have your two files, your custom action is ready to be deployed, using WSPBuilder, simply choose, “Deploy”. Refresh the page and go to a custom list, if everything goes well when you will click on the view item button, on the next page, above, you will see our “Import user” action. By clicking on it you will be redirected to google.
If in the elements.xml you change the location to Location=”Microsoft.SharePoint.StandardMenu” and include GroupID=”ActionsMenu”, your action will be now on the toolbar of the list in the Action menu and the click will redirect you again to google.
Have a nice day !
|
Apr
12
|
1: UserProfile u;
2: u[property].Value = "My string";
3: u.Commit();
1: SPSecurity.RunWithElevatedPrivileges(delegate()
2: {
3: using (SPSite site = new SPSite(web.Site.ID))
4: {
5: // your code
6: }
7: });
1: try
2: {
3: if (profileManager.UserExists("MOSS\\andy"))
4: {
5: //Do something
6: }
7: }
8: catch (UserNotFoundException ex)
9: {
10: //Do something
11: }
|
Apr
06
|
For my current development, one of the requirements is to be able to make some search through the Moss API or web service, so after some search on the web I discovered a really nice tool.
The SharePoint Search Services Tool, which allow you to directly do your request on the web services.
That tool is really awesome!
Make a request on a web services consist on 4 steps:
Get the value and scope you want to search on, generate the "Query Packet", which is simply create an XML formatted to be understood by the web service, make the request to it (via Query or QueryEx method), get the answer.
With that tool you will be able to:
The request window:
The Links
Download the SharePoint Search Services Tool from Codeplex: http://www.codeplex.com/SharePointSearchServ
Visual How-To access to the SharePoint wseb services: http://msdn.microsoft.com/en-us/library/bb625950.aspx
The QueryPacket element on MSDN: http://msdn.microsoft.com/en-us/library/ms451565.aspx
I’ve discovered a funny thing when I was searching some information about EnableUrlSmashing (I love the name), Microsoft created in 2006, published in 2008, a patent about the search API in SharePoint.
That patent ("Simplified search interface for querying a relational database") covers the Query, KeyWordQuery class and more.
An extract from the abstract:
Methods and computer-readable media are provided for performing a search on a relational database. According to one method, a query class is provided that includes properties that specify how a query is to be performed and how results from the query are to be returned, and an execute method that is called to perform the actual query. A keyword query class derived from the query class is also provided that includes keyword query properties and an execute method for performing the keyword query.
Link to the full patent: http://www.freepatentsonline.com/y2008/0114745.html
|
Apr
02
|
No, the blog isn’t transformed into a warez board, that’s the real thing.
Since the 03/31/2009, you can freely download it directly from the microsoft site, link is below.
After the news about setting a part of the BI stack of Microsoft, PerformancePoint, for free to the enterprise CAL customers, it’s now the turn of the SPD 2007 to be free.
That will probably leverage again a bit higher the reasons to go for SharePoint for the futures customers.
For the time being saying to them:"Ok you’ve bought an expensive piece of software even if it’s a killer-app, now you have to buy for each of you’re developers or designers a new office 2007 licence".
The answer is rather often:"Oh, it’s not included in SharePoint or Visual Studio ?"
And now I’m waiting for Infopath for free
The download link: