All About SharePoint

Liedong(Ken) Zheng,SharePoint Leader at SIMPLOT

Archive for January, 2009

Dynamically Add HTML Element To SharePoint

Posted by ken zheng on January 21, 2009

I have played with the javascript for Item ID in display and edit forms. The interesting part is you can add row into table by Javascript.

<script type="text/javascript">
//
// Item ID in DispForm.aspx and EditForm.aspx
// Feedback and questions: Christophe@PathToSharePoint.com
//
function DisplayItemID()
{
var regex = new RegExp("[\\?&]"+"ID"+"=([^&#]*)");
var qs = regex.exec(window.location.href);
var TD1 = document.createElement("TD");
TD1.className = "ms-formlabel";
TD1.innerHTML = '<h3 class="ms-standardheader">Issue ID</h3>';
var TD2 = document.createElement("TD");
TD2.className = "ms-formbody";
TD2.innerHTML = qs[1];
var IdRow = document.createElement("TR");
IdRow.appendChild(TD1);
IdRow.appendChild(TD2);
var ItemBody = GetSelectedElement(document.getElementById("idAttachmentsRow"),"TABLE").getElementsByTagName("TBODY")[0];
ItemBody.insertBefore(IdRow,ItemBody.firstChild);
}

_spBodyOnLoadFunctionNames.push("DisplayItemID");
</script>

Posted in JavaScript, Sharepoint | Tagged: , | 5 Comments »

The Content Editor Web Part

Posted by ken zheng on January 21, 2009

If you add scripts or styles, you’ll usually choose to hide the CEWP (check the “Hidden” box under Layout).

If you break your Web page…

When playing with the CEWP, you run the risk of adding bad code that will break your page. SharePoint will then throw out an error message, without offering any way to undo your changes.
If this happens to you, here is a useful trick: append the “?contents=1” querystring to your URL. It will give you access to the maintenance page, where you’ll be able to get rid of the faulty Web part.
For example, if you inadvertently break this page:

http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx

Enter:

http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx?contents=1

A trick to edit Web Part pages

On some pages, the edit option is not available or is grayed out. This is for example the case for the edit form of a list.
The workaround here is to append the “?ToolPaneView=2” querystring to your URL, which will switch your page to edit mode. Note that it seems to be unsupported by Microsoft, though I haven’t read an official confirmation.
For example, if you want to edit:

http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx

Enter:

http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx?ToolPaneView=2

Read full blog from here

Posted in Sharepoint | Tagged: | Leave a Comment »

SharePoint Designer Soap Server Error

Posted by ken zheng on January 16, 2009

YourURL?contents=1

This will put the page into the Maintenance mode mentioned in the error. From this page you can completely remove web parts from their pages.

webPartPageMaintenance

Its a good idea to check this every once and a while, because closed, unused web parts can still consume resources and slow down page loads.

Posted in Uncategorized | Leave a Comment »

World Clock and Weather SharePoint WebPart

Posted by ken zheng on January 16, 2009

The CKS World Clock and Weather web part allows users to display local time and weather for selected major cities from around the globe. You can download it from here.

After installing and adding to a page we received this error:

WebPart Error :: Method Name – OnPreRender :: [MESSAGE] – Unable to connect to the remote server

The issues ended up being with our proxy server. We added the defaultproxy to the web.config and the issue went away.

See here for more discussion

Posted in Sharepoint | Tagged: | 1 Comment »

Virtual Earth Map In SharePoint

Posted by ken zheng on January 15, 2009

Today I spent sometime to play around the Virtual Earth from WSSdemo, just adding to the demo. You need to Add List Webpart on the page then use SharePoint Designer to convert it to XSLT Web Part.

The pitty thing is you have to convert addresss to Lat and Long, I used site from here.

I am thinking to create a event receiver class to translate the Lan and Long Automatically.

Posted in Sharepoint | Tagged: | Leave a Comment »

JQuery Expand/Collapse All Groups in SharePoint

Posted by ken zheng on January 14, 2009

Just follow the idea of JQuery for Everyone: Expand/Collapse All Groups. I have deployed on a few SharePoint Pages by control id. Just use IE Dev Tool to get control id and replace
$("td.ms-toolbar[width='99%']").append(expandAll).append(collapseAll);
to
$("#ctl00_m_g_2e4a2a42_7e54_4a6e_ba80_923f50d3f0d5_Message").append(expandAll).append(collapseAll);

Posted in jQuery, Sharepoint | Tagged: , | Leave a Comment »

Clear InfoPath Form Cache in Local Computer

Posted by ken zheng on January 12, 2009

When loading an InfoPath form from an intranet/Sharepoint etc, the form template is downloaded and cached locally. Sometimes after the template has been upgraded on the server the local client doesn’t always get the upgraded form template but uses the local cached copy instead.

You can rectify this by clearing the local cache from Start -> Run;

Infopath /cache clearall
or VB Script

Dim wshShell
Dim sRun, sParam, sMsg

sParam = “C:\Program Files\Microsoft Office\OFFICE11\INFOPATH.EXE /cache clearall”
Set wshShell = Createobject(“WScript.Shell”)

wshShell.Exec sParam

Set wshShell = Nothing

Verify that the cache has been cleared by navigating to the following folder for XP+

C:\Documents and Settings\[User]\Local Settings\Application Data\Microsoft\InfoPath\FormCache2

Or for Vista;

C:\Users\[User]\AppData\Local\Microsoft\InfoPath\FormCache2

Underneath the FormCache2 folder there will be a folder with a GUID name, check inside here, it should be empty, apart from a file called _SCVer.dat.

Posted in Sharepoint | Tagged: | 2 Comments »

This solution contains no resources scoped for a Web application

Posted by ken zheng on January 12, 2009

If you get this error when try to deploy your solution, that means This solution contains no resources scoped for a Web Application and cannot be deployed to a particular Web application. You cannot use SharePoint Solution Installer or deploy by Central Admin. You can only use

%STSADM% -o deploysolution -name ImageScreenShot.wsp -local -force

Posted in Sharepoint | Tagged: | 3 Comments »

Hide the “View All Site Content” Quick Launch Link

Posted by ken zheng on January 7, 2009

To hide this link from all but those users with full control over a WSS site, open the site master page in SharePoint Designer and find the SPSecurityTrimmedControl element that contains a div with class ms-quicklaunchheader. The quickest route to this is to view the page in split view, and click on the “View All Site Content” link in the design pane.

The PermissionsString attribute of the SPSecurityTrimmedControl element determines what users can view this content. Change the value of this attribute to ManageWeb and only those users with rights to perform all admin tasks on the site will then be able to see the link on all pages in the site.

See this page for a list of all the possible permission string values.

All WSS templates that are also included in MOSS (including pages) actually inherit their setting from the System Master Page setting, not the Site Master Page setting. The Site Master Page is not used. Only in MOSS-specific templates, such as a Publishing site, is there Site Master Page usage and System Master Page usage. So to fix this, from the home page Master page settings page, select ‘System Master Page’ select the master page you want and check the ‘Reset all subsites’ option.

Here is the feature Mark Wagner wrote to hide the View All Content Link.
I also add some extra to hide the DIV box and Receyle Bin box. What you need to do is add
.ms-quicklaunchheader
{
display:none;
}
.ms-recyclebin
{
display:none;
}
into VASC-core.css
Here is the wsp file and vs2008 source code.

Posted in Sharepoint | Tagged: , | 3 Comments »

Add a Hyperlink To a SharePoint Event Outlook Export

Posted by ken zheng on January 6, 2009

You may have noticed that in a SharePoint event list, you can export an event list item as an iCalendar file. Although the link is generated script, you can create this link manually if you want to post it on another page or in an email for convenience. The format of the URL is as follows:

http://%5Bsite name]/_vti_bin/owssvr.dll?CS=109?Cmd=Display&CacheControl=1&List=[ListGUID]&ID=[EventID]&Using=Lists%2fEvents/event.ics

[site name] : This is the address of your Windows SharePoint Services site

[EventID] : This is the ID of the event, which you can get by looking in the URL when you are on the details page for that event.

[ListGUID] : This is the GUID of the list escaped. Yes, I know, this is tricky. The quickest way to get the GUID is to click on the “Modify Columns and Settings” link on the list’s page, and the GUID is in the URL. Escaping it simply requires replacing the front bracket with %7b the closing bracket with %7d and the dashes with %2d.

example: %7bBC04E0B5%2dB290%2d4D5E%2dB95C%2d3F16087246EE%7d
event.ics : You can change the name of the resultant file, but I wouldn’t recommend it. The operating system will know that it is an iCalendar file by the extension .ics, so don’t change it.

Posted in Uncategorized | Tagged: | 4 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 28 other followers