Wednesday, December 3, 2008

Programmatically customize site navigation in WSS 3.0 and MOSS 2007 - By Todd Baginski

I am summarizing one beautiful article from Todd about Adding/Updating/Deleting Navigation Items in sharepoint.

Here is an example of how to set a sub site not to use the navigation from a parent’s site.

SPSite noSharedNavSite = new SPSite(“http://server/test/nosharednav”);
SPWeb noSharedNavWeb = noSharedNavSite.OpenWeb();
noSharedNavWeb.Navigation.UseShared = false;
QuickLaunch Menu Items
Here is how you add a menu item to the QuickLaunch navigation menu.
These QuickLaunch examples assume you have created a top level site named quicklaunch.
Once this top level site has been created its URL will look like this: http://server/quicklaunch
In this example we will add two links to the QuickLaunch menu for the quicklaunch
top level site, one link will be internal and one will be external. The internal
link will point to the Links list in the QuickLaunch site. The external
link will point to the SharePoint Experts web site.

SPSite quickLaunchSite = new SPSite(“http://server/quicklaunch”);
SPWeb quickLaunchWeb = quickLaunchSite.OpenWeb();
SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;
SPNavigationNode internalMenuItem = new SPNavigationNode(“Links”, “Lists/Links/AllItems.aspx”, false);
quickLaunchNodes.AddAsFirst(internalMenuItem);
SPNavigationNode externalMenuItem = new SPNavigationNode(“SharePoint Experts”,
“http://www.SharePointExperts.com”, true);
quickLaunchNodes.AddAsFirst(externalMenuItem);
quickLaunchWeb.Update();
*Note: If you do not call the Update() method on the SPWeb object you are working
with, you will need to reset IIS to see your changes.
Here is what the quicklaunch Site Collection looks like after the above code has
been executed:

Here is how you remove a menu item from the QuickLaunch navigation menu.
In this example we will remove the external link to the SharePoint Experts web site.
SPSite quickLaunchSite = new SPSite(“http://server/quicklaunch”);
SPWeb quickLaunchWeb = quickLaunchSite.OpenWeb();
SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;
quickLaunchNodes.Delete(quickLaunchNodes([0]));
quickLaunchWeb.Update();
Here is what the quicklaunch Site Collection looks like after the above code has
been executed:

Taking the QuickLaunch menu one step further
The QuickLaunch menu is capable of displaying links in a grouped fashion, as you see
in the screenshot above. For example, the Lists menu item in the screenshot
above has two items under it – the Calendar and Tasks links. Creating your own
grouped links can be done programmatically. This is once again a simple process
that requires very little code.
Here is how you add grouped menu items to the QuickLaunch navigation menu.
In this example create a header link for the group of links and name it
Administration. Then we will add two links under the Administration header link.
The links will link to the Create and Site Settings pages for the
quicklaunch Site Collection.
SPSite quickLaunchSite = new SPSite("http://" + serverTextBox.Text + "/quicklaunch");
SPWeb quickLaunchWeb = quickLaunchSite.OpenWeb();
SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;
SPNavigationNode internalMenuItem = new SPNavigationNode("Administration", "", false);
quickLaunchNodes.AddAsFirst(internalMenuItem);
SPNavigationNode externalSubMenuItem1 = new SPNavigationNode("Site Settings",
quickLaunchWeb.Url + "/_layouts/settings.aspx", true);
quickLaunchNodes[0].Children.AddAsFirst(externalSubMenuItem1);
SPNavigationNode externalSubMenuItem2 = new SPNavigationNode("Create",
quickLaunchWeb.Url + "/_layouts/create.aspx", true);
quickLaunchNodes[0].Children.AddAsFirst(externalSubMenuItem2);
quickLaunchWeb.Update();
Here is what the quicklaunch Site Collection looks like after the above code has
been executed:
href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh3aWGZatNNPic81FuwQVmNATKvSvkVtj6RMQ94JG2Whd1KpfbTYPGK9Fafv_qg2R4QWFmlYO2MGT6GkMs-aCwqZQt3yZEBkO_RF_7wuTIjrfSKCfYCwFg-hZl83DV7drFe0V19OuA3BCx/s1600-h/sitenav7.jpg">
Top Navigation Menu Items

SPSite topNavigationSite = new SPSite(“http://server/topnavigation”);
SPWeb topNavigationWeb = topNavigationSite.OpenWeb();
SPNavigationNodeCollection topNavigationNodes =
topNavigationWeb.Navigation.TopNavigationBar;
SPNavigationNode internalMenuItem = new SPNavigationNode(“Links”, “Lists/Links
/AllItems.aspx”, false);
topNavigationNodes.AddAsFirst(internalMenuItem);
SPNavigationNode externalMenuItem = new SPNavigationNode(“SharePoint Experts”,
“http://www.SharePointExperts.com”, true);
topNavigationNodes.AddAsFirst(externalMenuItem);
topNavigationWeb.Update();
Here is what the topnavigation top level site looks like after the above code has
been executed:

Here is how you delete a menu item from the top navigation menu. In this example we
will remove the Links link we just added to the top navigation menu for the
topnavigation top level site.
SPSite topNavigationSite = new SPSite(“http://server/topnavigation”);
SPWeb topNavigationWeb = topNavigationSite.OpenWeb();
SPNavigationNodeCollection topNavigationNodes =
topNavigationWeb.Navigation.TopNavigationBar;
topNavigationNodes.Delete(topNavigationNodes[0]);
topNavigationWeb.Update();
Here is what the topnavigation top level site looks like after the above code has
been executed:

Taking the Top Navigation one step further
The top Navigation menu is capable of displaying dropdown menus that consist of
multiple items. Adding additional sub menu items under the topmost item is a
simple process and requires very little code.
Here is how you add a sub menu item to a top level menu item in the top navigation
menu. In this example we will add a new top level menu item to the top
navigation menu that has two sub menu items under it for the topnavigation top
level site.
SPSite topNavigationSite = new SPSite(“http://server/topnavigation”);
SPWeb topNavigationWeb = topNavigationSite.OpenWeb();
SPNavigationNodeCollection topNavigationBarNodes =
topNavigationWeb.Navigation.TopNavigationBar;
SPNavigationNode headerMenuItem = new SPNavigationNode("SharePoint Sites", "",
false); topNavigationBarNodes.AddAsFirst(headerMenuItem);
SPNavigationNode externalSubMenuItem1 = new SPNavigationNode("SharePoint Experts",
"http://www.SharePointExperts.com", true);
topNavigationBarNodes[0].Children.AddAsFirst(externalSubMenuItem1);
SPNavigationNode externalSubMenuItem2 = new SPNavigationNode("SharePoint
University", "http://www.SharePointU.com", true);
topNavigationBarNodes[0].Children.AddAsFirst(externalSubMenuItem2);
topNavigationWeb.Update();
Here is the code used to add the links:

SPSite topNavigationSite = new SPSite(“http://server/topnavigation”);
SPWeb topNavigationWeb = topNavigationLaunchSite.OpenWeb();
SPNavigationNodeCollection topNavigationBarNodes =
topNavigationWeb.Navigation.TopNavigationBar;
SPNavigationNode headerMenuItem = new SPNavigationNode("Administration", "", false);
topNavigationBarNodes.AddAsFirst(headerMenuItem);
SPNavigationNode externalSubMenuItem1 = new SPNavigationNode("Site Settings",
topNavigationWeb.Url + "/_layouts/settings.aspx", true);
topNavigationBarNodes[0].Children.AddAsFirst(externalSubMenuItem1);
SPNavigationNode externalSubMenuItem2 = new SPNavigationNode("Create",
topNavigationWeb.Url + "/_layouts/create.aspx", true);
topNavigationBarNodes[0].Children.AddAsFirst(externalSubMenuItem2);
topNavigationWeb.Update();


Link to Original Article

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 .

Tuesday, September 23, 2008

Bulk Editing of SharePoint List Items

Imagine you have a list with a “Confirm” yes/No field and you want a user to be able to view items and click a Check box on those items which are completed and click a Save button:

Bulkedit1

This saves the user opening each item in turn, changing the “Confirm” field and saving the item. This can be done using the SharePoint Designer and using a DataView. To do this:

  • Select File + New + Page to create a new ASPX page.
  • Choose “Create from Master Page…” and click OK and OK again to use the default master page..
  • Save the page as “BulkEdit.aspx” in the list’s folder, e.g. “ConfirmList” where the existing AllItems.aspx file exists.
  • “Create Custom Content” for “PlaceHolderMain” using the quick link:

Bulkedit2

  • Open the Data View >Manage Data Source . Click on “Data Source Library” pane on right of screen and click the list, e.g. “ConfirmList” and select Show Data:

Bulkedit3

  • Select the Insert Selected Fields as… button in the Data Source Details panel and select Multiple Item Form:

Bulkedit4

  • From the “Data View” menu select Edit Columns and remove all columns bar “Title” and “Confirm” (or whatever columns you want displayed).

You will now set the “Title” column to be read-only so that only the “Confirm” check box is editable.

  • Single click a “Title” edit box and click the “Common FormField Tasks” button (the greater than sign)or top right corner and select “Text” from the “Format as” list.
  • Save the file.
  • To test, navigate to the page, e.g. TestSite/Lists/ConfirmList/bulkedit.aspx.

Also take a look at http://office.microsoft.com/en-us/sharepointdesigner/HA101191141033.aspx, this uses an XML file as the data source rather than a SharePoint list.

A solution to "An unexpected error has occurred" in WSS v3

Debugging SharePoint can be problematic at times, it does like to hide debugging information from you. The bain of my life recently has been “An unexpected error has occurred” with nothing written to log files, trace or the event log.

Normally I can debug the problem with a little commenting & narrowing down of the problem, but today I have managed to get rid of that error screen completely.

The solution is to change a single entry in web.config, by modifying the line… ( change [ ] Braces to < Braces)

[SafeMode MaxControls=“200“ CallStack=“false“…

to…

[SafeMode MaxControls=“200“ CallStack=“true“…

You will also need to set custom errors to 'Off' .

[customErrors mode=“Off“/]

You will no longer see the “An unexpected error has occurred” error page and instead you get a lovely ’standard ASP.Net error page’ with the stack trace and everything…development has got that little bit easier!!

Wednesday, September 17, 2008

WebPart Connections getting information from Property page - By Paul Culmsee

Wouldn’t it be great if we could somehow pass the device name (or some other device information) to the report web part automatically.

That way, each time you opened up a device entry, the report would retrieve performance information for the device currently being viewed. That would be very, very cool.

Fortunately for us it can be easily done. The report services web part, like many other web parts is connectable. This means that it can accept information from other web parts. This means that it is possible to have the parameters automatically passed to the report!

Wohoo!

So here is how I am going to do this. I am going to add two new columns to my device list. Each column will be the parameter passed to the report. This way, I can tailor the report being generated on a device by device basis. For example, for a SAN device I might want to report on disk I/O, but a server I might want CPU. If I store the parameter as a column, the report will be able to retrieve whatever performance data I need.

Below shows the device list with the additional two columns added. the columns are called TAGPARAM1 and TAGPARAM2. The next screen below, shows the values I have entered for each column against the device DM01. These values will be passed to the report server report and used to find matching performance data.

image image

So the next question becomes, how do I now transparently pass these two parameters to the report? We now have the report and the parameters on the same page, but no obvious means to pass the value of TagParam1 and TagParam2 to the report viewer web part.

The answer my friends, is to use a filter web part!

Using the toolpane view hack, we once again edit the view item page for the Device List. We now need to add two additional web parts (because we have two parameters). Below is the web part to add.

image

The result should be a screen looking like the figure below

image

Filter web parts are not visible when a page is rendered in the browser. They are instead used to pass data between other web parts. There are various filter web parts that work in different ways. The Page Field filter is capable of passing the value of any column to another web part.

Confused? Check out how I use this web part below…

The screen above shows that the two Page Field filters web parts are not configured. They are prompting you to open the tool pane and configure them. Below is the configuration pane for the page field filter. Can you see how it has enumerated all of the columns for the "IT device" list? In the second and third screen we have chosen TagParam1 for the first page filter and TagParam2 for the second page filter web part.

image image image

Now take a look at the page in edit mode. The page filters now change display to say that they are not connected. All we have done so far is tell the web parts which columns to grab the parameter values from

image

Almost Home - Connecting the filters

So now we need to connect each Page Field filter web part to the report viewer web part. This will have the effect of passing to the report viewer web part, the value of TagParam1 and TagParam2. Since these values change from device to device, the report will display unique data for each device.

To to connect each page filter web part you click the edit dropdown for each page filter. From the list of choices, choose "Connections", and it will expand out to the choice of "Send Filter Values To". If you click on this, you will be promoted to send the filter values to the report viewer web part on the page. Since in my example, the report viewer web part requires two parameters, you will be asked to choose which of the two parameters to send the value to.

image image

Repeat this step for both page filter web parts and something amazing happens, we see a performance report on the devices page!! The filter has passed the values of TagParam1 and tagParam2 to the report and it has retrieved the matching data!

image

Let’s now save this page and view it in all of its glory! Sweet eh!

image

Credit : Paul Culmsee

Link to Original Post : http://www.cleverworkarounds.com/2008/08/09/aint-it-cool-integrating-sharepoint-and-real-time-performance-data-part-2/

Remove "New" icon from newly added Document using JavaScript

Adding JavaScript to a page inside a Content Editor web part can be a great way to perform on-the-fly customizations to your SharePoint sites. This worked great in WSS v2 and SPS 2003. We started noticing that some of those scripts didn’t seem to work in WSS v3 and MOSS 2007, however, and it wasn’t because the names of objects and elements had changed.

For example, here is a JavaScript snippet that we had used to hide the “NEW!” icon on a page in WSS v2.

Note: In all code examples below, replace the square brackets around the SCRIPT tags with angle brackets. If I included the angle brackets, the browser tried to execute the code. :o(
[script language="JavaScript"]
var fields,i;
fields = document.getElementsByTagName('IMG');
for( i = 0; i < fields.length; i ++ ) {
 var imgsrc = fields[i].getAttribute('SRC');
 if(imgsrc.indexOf("new.gif") != -1) {
  fields[i].style.visibility = "hidden";
 }
}
[/script]

When we added this to a Content Editor web part in a WSS v3 page, nothing seemed to happen. I added code to make it run on the onLoad event, and that didn’t work either. I did a little experimentation and discovered that if I added a short delay, even a delay of 1/1000 of a second, it worked fine. I placed the core code within a function and then called it with the setTimeout() method.

[script language="JavaScript"]
setTimeout(HideNewIcons,1);
function HideNewIcons(){
 var fields,i;
 fields = document.getElementsByTagName('IMG');
 for( i = 0; i < fields.length; i ++ ) {
   var imgsrc = fields[i].getAttribute('SRC');
   if(imgsrc.indexOf("new.gif") != -1) {
    fields[i].style.visibility = "hidden";
   }
 }
}
[/script]

The problem occurs because most WSS v3 pages use a master page that contains the “body” element, and the page content code loads after the master page code. I didn’t know it at the time, but recently discovered (thanks to this article on the Microsoft SharePoint Products and Technologies Team Blog) that the SharePoint developers had given us a way to work around that issue—it’s the _spBodyOnLoadFunctionNames array. We can use JavaScript’s “push” method to load items into this array where they will run when the body’s onLoad event fires .

Here is what the JavaScript looks like with the setTimeout replaced with a line that pushes the function name “HideNewIcons” into the _spBodyOnLoadFunctionNames array.

[script language="JavaScript"]
_spBodyOnLoadFunctionNames.push("HideNewIcons");
function HideNewIcons(){
 var fields,i;
 fields = document.getElementsByTagName('IMG');
 for( i = 0; i < fields.length; i ++ ) {
   var imgsrc = fields[i].getAttribute('SRC');
   if(imgsrc.indexOf("new.gif") != -1) {
    fields[i].style.visibility = "hidden";
   }
 }
}
[/script]

If you’ve been having trouble getting some of your legacy JavaScript scripts to run from within Content Editor web parts in WSS v3 or MOSS 2007 pages, give this technique a try, and let me know if it works for you.

Credit : Rickey Spears

Show Quick launch bar in all pages in MOSS including System page

Many times we come across to a situation where you are updating a item in a list or document library Or you are Viewing the item and you want to quickly navigate to any list, then all you need is go back to default.aspx of yor site and then go from there. so question is : how to show quick luanch bar in All pages in Moss site? If we find a way where we can have that quick launch bar visible on eveypage, so that we can navigate to anywhere from anywhere. So here is a trick to go for this : (1)open your master page ( Better to create your own and attaching it with your site collection, otherwise it will affect whole farm setup) And better to take the backup of even your master pages before doing anything in them. (2) Search for the following content : div class="ms-quicklaunchouter"> div class="ms-quickLaunch" style="width:100%"> h3 class="ms-standardheader"> You will find these content in one contentplaceholder. This tag is : asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"> /asp:ContentPlaceHolder> So cut all the code inside this start tag and end tag and paste it outside of endtag of that contentplaceholder. That's it. your job is done: See the below figures after applying change : Above figure : EditForm.aspx Above figure : NewForm.aspx Above figure : DispForm.aspx Source: http://www.sharepointkings.com/2008/07/show-quick-launch-bar-in-all-pages-in.html

Make Edit Page option available in list forms like NewForm.aspx, EditForm.aspx and DispForm.aspx

Most common question among SharePoint customization is that
“Why Edit Page option is not available in list forms like NewForm.aspx, EditForm.aspx and DispForm.aspx?”
If we need to edit New/Edit/Display Form of list most of the time we are using SharePoint designer. But here is the one nice trick to achieve this functionality. Just add “&ToolPaneView=2” at the end of the URL and refresh the page. So that you’re URL will be like this.
http://sharepointkings/... /Lists/Demo/NewForm.aspx?RootFolder...&Source=…&ToolPaneView=2 http://sharepointkings/... /Lists/Demo/EditForm.aspx?RootFolder...&Source=…&ToolPaneView=2 http://sharepointkings/... /Lists/Demo/DispForm.aspx?RootFolder...&Source=…&ToolPaneView=2
You can see add webpart tool pan beside this web part.

Just add or remove your webpart and your work is done. Updated :

Let's examine the command: The MSO presumably stands for Microsoft Office, the TlPn (that's a lowercase L not a 1 and unfortunately JavaScript is case sensitive) presumably stands for Tool Pane, and ShowToolPane is the specific method that we are executing. The required ViewID parameter identifies which Tool Pane view to show:

ViewID Tool Pane view to show
-1 Extensible View
0 Close task pane
1 Web Part Properties and Custom ToolParts
2 Add Web Parts – Browse
3 Add Web Parts – Search
4 Navigation (Downlevel only)
5 Add Web Parts – Import
6 Web Part Menu (Downlevel only)
7 Error

Monday, September 15, 2008

Using Javascript to Hide fields in Editform.aspx and Newform.aspx

Methods of Hiding column entry tab from newform.aspx and editform.aspx forms

Method 1 : The first solution is to customize NewForm.aspx from SharePoint Designer and replace the default list form with Custom List Form, in which you can remove the fields you don't need.

Method 2 : Next is to customize NewForm.aspx and add a JavaScript code that hides the whole row the field is placed.

We have implemented method 2 for the system implementation. We will discuss it in detail.

getTagFromIdentifierAndTitle

The most important part of our solution is the “getTagFromIdentifier” function. This function finds the HTML element rendered by a given SharePoint FormField control. It takes the following parameters:

  • tagName – The name of the tag rendered in the form’s HTML
  • identifier – The string associated with the SharePoint type of the relevant field
  • title – The value of the relevant HTML tag’s “title” attribute, which also matches the field’s display name

Here’s a partial table of SharePoint column types and their corresponding “identifiers” and “tagNames”:

SharePoint Field Type

Identifier

tagName

Single Line of Text

TextField

input

Multiple Lines of Text

TextField

textarea

Number

TextField

input

Currency

TextField

input

Choice (dropdown)

DropDownChoice

select

Lookup (single)

Lookup

select

Lookup (multiple)

SelectCandidate; SelectResult

select

Yes/No

BooleanField

input

Date Time

DateTimeFieldDate

input

For hiding “Assigned to” field:: getTagFromIdentifierAndTitle("div", "", "People Picker");

JavaScript code :

<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideFields");

function hideFields() {

var control = getTagFromIdentifierAndTitle("TAGNAME","IDENTIFIER","FIELD NAME");

control.parentNode.parentNode.parentNode.style.display="none";

}

function getTagFromIdentifierAndTitle(tagName, identifier, title)

{

var len = identifier.length;

var tags = document.getElementsByTagName(tagName);

for (var i=0; i[tags.length; i++)

{

var tempString = tags[i].id;

if (tags[i].title == title && (identifier == ""

tempString.indexOf(identifier) == tempString.length - len))

{

return tags[i];

}

}

return null;

}

[/script]

Thursday, April 24, 2008

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...