Tuesday, October 7, 2008

SharePoint Tip - Shortcut to 12 hive with ease

I have to go to 12 Hives from command prompt so often that i looked for a better
solution to reach there . Here is what you have to do:
(1) Create a new text file in notepad and write the path to 12 hives like this :
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12
(2) Save the file as 12.cmd
(3) Copy the file and put it inside c:\Windows folder
(4) Job done... from anywhere in command prompt as soon as you press 12 , you get to
12 hives of sharepoint..
;)

Friday, October 3, 2008

Creating a Scope and Tab for MOSS Search Center -By : Scot Hillier

I found a good article from Scot About Creating a Scope and Tab for MOSS Search
Center. Here is a direct link to the Article : Click Here

Create the new Search Center Tab


New tabs for Search Center involve several different parts. First, you must create a
search page. Then you must create a search results page. Finally, you must
associate the scope with the new pages and create tabs to display them. Follow
these steps to get it all working:

1. From the Search Center page, select Site Actions>>Create Page

2. On the Create Page

- Enter HR Documents Search in the Title field
- SharePoint should automatically generate a valid page name
- Select "Search Page" from the list of available Page Layouts
- Click the Create button

3. A new page should now be visible with a Search Box web part

- Select Modify Shared Web Part from the web part's edit menu
- Expand the Miscellaneous section
- Enter HRDocumentsResults.aspx in the Target Search Results Page URL field
(you will create this page next)
- Uncheck the box labeled "Display Advanced Search Link"
- Click the OK button
- Click the Publish button at the top of the page

4. From the new page, select Site Actions>>Create Page

5. On the Create Page

- Enter HR Documents Search Results in the Title field
- SharePoint should automatically generate a valid page name
- Select "Search Results Page" from the list of available Page Layouts
- Click the Create button

6. A new page should now be visible with a several search web parts

- Select Modify Shared Web Part from the Search web part's edit menu
- Expand the Miscellaneous section
- Enter HRDocumentsResults.aspx in the Target Search Results Page URL field
- Uncheck the box labeled "Display Advanced Search Link"
- Click the OK button
- Select Modify Shared Web Part from the Search Core Results web part
- Expand the Miscellaneous section
- Enter HR Documents in the Scope field
- Click the OK button
- Click the Publish button at the top of the page

7. From the new page, select Site Actions>>View All Site Content

8. On the All Site Content page, click the "Tabs in Search Pages" link

9. On the Tabs in Search Pages list, click the New button

10. On the New Item page

- Enter HR Documents in the Tab Name field
- Enter HRDocumentsSearch.aspx in the Page field
- Click the OK button

11. From the list, select Site Actions>>View All Site Content

12. On the All Site Content page, click the "Tabs in Search Results" link

13. On the Tabs in Search Results list, click the New button

14. On the New Item page

- Enter HR Documents in the Tab Name field
- Enter HRDocumentsSearchResults.aspx in the Page field
- Click the OK button

Return to the Search Center home page and you should now see a new tab visible for
HR Documents.

Migrating Site / SubSite / Content and Content Deployment Tool from Chris O' Brien

If you came across situation like these :
* I just need to move this document library from A to B
* I just need to move these selected files (e.g. master page, page layouts, CSS

etc.) from A to B
* I just need to move this web from A to B
* I just need to move this site collection from A to B
* I just need to move these 20 list items from A to B

Then Chris O'Brien is here for rescue.
I know there are other 2 methods to accomplish the same task :

(1) Using Sharepoint designer tool to Backup and restore the site
(2) Stsadm.exe command line tool

The only thing i dint like about these two methods is the limitation of what you can migrate.
Sharepoint designer allows site migration of size with 25 MB or below. Also Both methods
want you to create an empty site before export of data.
Then I found a very handy tool for migrating my stuff from one site collection to another. This
tool designed by Chris O' Brien is so Cool, The migration of Stuff becomes so so easy. It is
a must see tool for all SharePoint Developer. The new and better 1.1 version is released
in CodePlex , This time he has Provided the Code of the Content Deployment Wizard as
well.
You Can Learn about the Product Here
You can learn on product operation Here
You can directly download the latest Version of Product as well as the source code Here

Job done with little pain ;)

Thursday, October 2, 2008

Attach Custom Button on Editform.aspx and Newform

Including the "Custom " Button to the Page
Open the SharePoint Site containing the List to modify using SharePoint Designer
2007 and use the Folder List to navigate to the target List under the folder Lists
(In this example, I will be using the Links list that comes along with any site
created using the Team Site site template). Double click on the NewForm.aspx page.
The NewForm.aspx page would open in code view. Identify the Content control with the
ContentPlaceHolderId of PlaceHolderMain. We will be actively inserting extra
JavaScript and HTML within this Content control that will alter the behavior of the
page. First of all, let's insert the appearance of the 2 HTML elements that we will
be inserting into the rendered page. The <table> element here is made hidden
as it serves no purpose but as a "host" to the 2 <td> elements that
are marked with their respective IDs which we will be using later. Note that the
first <td> element contains the "OK and New" button that will
perform certain custom JavaScript function when clicked upon. We will be diving into
the JavaScript function's details later. Insert the HTML code right above the
closing tag of the Content control </asp:Content>.

<table style="display:none">
<tr>
<td id="oCustomButton" class="ms-toolbar" nowrap="true">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="right" width="100%" nowrap>
<input type="button" value="Custom Button"
onclick="submitForm()" class="ms-ButtonHeightWidth" target="_self" />
</td>
</tr>
</table>
</td>
<td id="oSeparator" class="ms-separator"> </td>
</tr>
</table>

Next task is inserting the relevant elements into the right position on the page,
such that it appears next to the OK button, along the Cancel button as well.
Insert the following JavaScript code into a script element into the page right below
the above pasted HTML codes:

<script language="javascript" type="text/javascript">
function attachCustomButton()
{ var oAryTables = new Array();
var oCustomButton = null;
var oSeparator = null;
var oNodeTemp = null;
oCustomButton = document.getElementById("oCustomButton");
oSeparator = document.getElementById("oSeparator");
oAryTables = document.getElementsByTagName("table");
for(var i = 0; i < oAryTables.length; i++)
{ if(oAryTables[i].className == "ms-formtoolbar")
{ oNodeTemp =
oAryTables[i].firstChild.firstChild.insertBefore(oSeparator.cloneNode(true),
oAryTables[i].firstChild.firstChild.firstChild.nextSibling);
oAryTables[i].firstChild.firstChild.insertBefore(oCustomButton.cloneNode(true),
oNodeTemp);
}
}
} _spBodyOnLoadFunctionNames.push("attachCustomButton");
</script>

Now write your own code for the ButtonClick Event.
;)

Add New Event to Buttons of default Newform.aspx, Dispform.aspx and Editform.aspx

There comes a situation when you want the default Ok or Edit item or close buttons 
in SharePoint forms pages like Newform.aspx, Dispform.aspx and Editform.aspx to
 redirect user to new page then specified.

To do that we can use java script code to redirect users to different page then the
 normal ones.
I am using an instant of giving an alert to user when user clicks on Ok button of 
editform.aspx .

I am using content editor webpart to add javascript code to editform.aspx page.
You can look into by earlier post if you are not aware of method to put content 
editor webpart in editform.aspx page.

Here is the post click here
After the Webpart is added, make sure the Inside Layout Tab, the Hidden checkmark is
 checked, to hide the webpart during normal use.

In the content editor webpart , put this javascript code:
Replace [] with < >



[script language="javascript" type="text/javascript"]

_spBodyOnLoadFunctionNames.push("StartUpCustomScript");
function StartUpCustomScript() {  
  ChangeOkButtonOnclickEvent("Input","SaveItem");
}
function ChangeOkButtonOnclickEvent(tagName, identifier) {
  var len = identifier.length;
  var tags = document.getElementsByTagName(tagName); 
 /*find all Input type controls on page (ie. control with tag [Input/])*/
  for (var i=0; i < tags.length; i++) {
        var tempString = tags[i].name;       
        if(tempString.indexOf(identifier) == tempString.length-len ) /*find any 
Input type controls on page has its name ending with 'SaveItem'*/
        {
           /*if found, replace it default onclick with our custom script*/

           var func = tags[i].attributes["onclick"].value.replace("if 
(!PreSaveItem())","alert('you have clicked OK');if (!PreSaveItem())");
           /*remove its default onclick event*/
           tags[i].onclick = null;
           /*re-register its onlick event with new script*/
           tags[i].attachEvent("onclick",new Function(func));
       }
    }
    return null;
}  
[/script]




Adding this now as soon as from editform.aspx when you click Ok button , a alert 
message will pop up.



Job done :)

Wednesday, October 1, 2008

Writing Custom Web Services for sharepoint 2007

There is a good Article on Building Sharepoint web services on MSDN :
You can View the Article here : http://msdn.microsoft.com/en-us/library/ms916810.aspx But the articles is for sharepoint 2003.
There is one more good Article in "toolbox for IT" which i found and seems to be a derived into much simpler form from MSDN Article.
You can view the article here : http://it.toolbox.com/blogs/sharepoint-blog/creating-a-custom-web-service-for-sharepoint-13553
But The above articles are for sharepoint 2003 . Its almost the same for 2007 but you have to make some changes to accomodate it in 2007 .
Here are 2 things you have to take care:

1. location to drop dll file: there is no \ISAPI\BIN in MOSS2007 (at least for now) put the dll in ASP.NET vitrual directory e.g. C:\Inetpub\wwroot\wss\VirtualDirectories\(sharepoint port:80)\_app_bin\mydllname.dll
2.Also make sure inside your .asmx file you have named your dll e.g.

[%@ WebService Language="c#" Class="mypackage.myclass,mydllname" %]

( Replace [ ] code on top with < > code)

Rest is all the same , and should work fine for you .

RootComponent types in solution.xml file in Dynamics CRM 365/2016

In Microsoft Dynamic CRM 2016/365 are you as confused as me when looking at the solution.xml from the solution export? looking at the xml a...