sharepointking

Just another WordPress.com site

Monthly Archives: August 2008

How to Add description below Lable of Field in Sharepoint Form : Solution is here

Add following javascript at appropriate location on sharepoint form or if you are using your own custom field control on form then you just need to add following block between script block

_spBodyOnLoadFunctionNames.push(‘JustifyReason’);

function JustifyReason() {

//find site type dropdown list
var objSiteType = getTagFromIdentifierAndTitle(“select”,”DropDownChoice”,”Site Type”);
if(objSiteType !=null)
{
//objSiteType.multiple= ‘multiple’;
objSiteType.size= ’15’;
objSiteType.style.height= 150;
var str = “To select site type for your purpose from selection box. Demo By Vaibhav”;
var newtxt =document.createTextNode(str);
objSiteType.parentNode.parentNode.parentNode.childNodes(0).appendChild(newtxt);
}

}
// to get control id
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;
}

Complete Sharepoint Forum Webpart

Create workflow step by step (WSS 3.0 and MOSS2007)

Serge’s article is well-written and well-illustrated. It looks like three of twenty articles have been published so far, but clearly his complete article will be an authoritative guide worth bookmarking for future reference.

http://sergeluca.spaces.live.com/blog/cns!E8A06D5F2F585013!859.entry?_c=BlogPart

How to make Choice Box looks like Listbox in Sharepoint

During field type selection if you select choice that means values will be display in dropdown list now if you say i want to show values users from dropdown to listbox with single selection then follow following step:

add javascript of following at appropriate location in your sharepoint list form OR If you are using any of custom field control then you can put below block in that user control to manage above situation for any choice control in whole form.

_spBodyOnLoadFunctionNames.push(‘JustifyReason’);

function JustifyReason() {

//find site type dropdown list
var objSiteType = getTagFromIdentifierAndTitle(“select”,”DropDownChoice”,”Site Type”);
if(objSiteType !=null)
{
//objSiteType.multiple= ‘multiple’;
objSiteType.size= ’15’;
objSiteType.style.height= 150;

}

}

// to get control id
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;
}

NOW YOUR CHOICE BOX WILL LOOK LIKE BELOW:

From MOSS Toolbar remove singel file upload

You can upload the single file with multiple file upload menu.

I though let me hide that manu just for a fun purpose.

(1) Add content editor webpart on AllItems.aspx of your document library.
(3) Open Source editor
(4) Paste the following lines of code and see, your single upload will get disabled

function GetElementByText(tagName, title)
{
var a = document.getElementsByTagName(tagName);

for (var i=0; i < a.length; i++)
{
if (a[i].text)
{
if (a[i].text === title)
{
return a[i];
}
}
}

return null;
}

if (window.onload)
{
var oLoad = window.onload;
window.onload = function bodyLoad()
{
oLoad();

var o = GetElementByText(“ie:menuitem”,”Upload Document”);
if (o)
{
o.disabled = true;
}
}
}

Cheer.

Worthless to create NEW security group in case of “Use same permission as parent site”

In case of inheritance I have checked that we are not able to assign permission level without STOP inherit from parent website. I have observed that you can assign permission level at newly created security group at site level but the fact in this case is SharePoint will ask to STOP inherit permission and convert it into “Unique Permission” level.

So in bottom line if we create new groups e.g. Americas Operations Demosite Administrator with option “Use same permission as parent site” as SharePoint current Security model will not allow you to assign permission level without breaking inheritance that you can see in below screen. That means in case of ANY SITE CREATION if we create our own groups then it will be worthless without permission e.g. Americas Operations DemoSite Administrator.

How to add ‘Save site as template’ Link to Site Settings in WSS v3/MOSS 2007 using a CustomAction Feature"? solution is here.

“Save site as template” link is only available under the Look and Feel menu of Site Settings at the Top Level of the site collection in WSS v3/MOSS 2007 Beta 2. For all subsites, Shane advises to append “_layouts/savetmpl.aspx” to the URL in order to get to the Save Site as Template page.

The SaveSiteAsTemplate feature will consist of a Feature.xml and an Elements.xml file. Feature.xml declares the Feature itself, and Elements.xml further defines the CustomAction for the Look and Feel menu on a Site Settings page. To get started, create a folder named SaveSiteAsTemplate below the Features folder located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES on your WSS v3 server. Create Feature.xml and Elements.xml from the code below and place each file in the SaveSiteAsTemplate folder you just created.

Feature.xml

<Feature Id="DE98E72D-80FF-4031-88B0-2E4DEF6312C8"

Title=”Save Site As Template”

Description=”Adds a ‘Save Site As Template’ link to the Look and Feel menu in Site Settings.”

Version=”1.0.0.0″

Scope=”Web”

Hidden=”FALSE”

xmlns=”http://schemas.microsoft.com/sharepoint/&#8221; >

Note the Scope attribute in the Feature element of Feature.xml. Scope can be set to either Farm, WebApplication, Site or Web. Also notice that the ElementManifest element points to Elements.xml.

Elements.xml

<CustomAction

Id=”SPSolutions.SaveSiteAsTemplate”

GroupId=”Customization”

Location=”Microsoft.SharePoint.SiteSettings”

Sequence=”1000″

Title=”Save site as template”>

Setting the Location of the CustomAction to Microsoft.SharePoint.Settings and the GroupId to Customization is what decides where the link will be render in the UI.

Next, install the feature into WSS v3 by using the stsadm tool. Stsadm.exe is located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on your WSS v3 server.

stsadm -o installfeature -name SaveSiteAsTemplate

Finally, activate the new feature on your WSS Site by going to Site Settings > Site Features and clicking the Activate button for the new Save Site As Template feature.

NOW YOU CAN SEE LINK IN SITE SETTINGS –> LOOK AND FEEL –> SAVE SITE AS A TEMPLATE

How to get currently logged-in user in workflow

Hi All,

you will always have simple requirement whenever you are working with workflow is to find the currently logged-in user.

It is really frustrating that it is easy to find who is the originator of the workflowproperties but you cannot find who is currently logged in user from workflowproperties even you have properties available.

Let me give you the scenario.

I assume that you have WorkflowProperties object.

So if you write ,

workflowProperties.OriginatorUser.ID
workflowProperties.OriginatorUser.Name
workflowProperties.OriginatorUser.ID.LoginName

you will get everything,

but if you write,

workflowProperties.Web.CurrentUser.Name

All you get is only system account, even the properties from the name looks like it will return you current logged in user. but it actually doesn’t.

so why is it not returning it? what can be the reason.

Reason is Workflow actually does not run in the same session or same context, because workflow is to be hosted and to be called from the application by setting up the connection.

So it can be called up by any other application,office applications or any other source, it cannot be always the MOSS that triggers the workflow, and even if you triggers the Workflow from MOSS environment, it will still return you System Account.

so, how to get the Currently Logged-in User?

Here is a trick that i found.

string ModifiedbyUserName = Convert.ToString(workflowProperties.
Item.GetFormattedValue(“Modified By”));

This will give you the person who has modified the item, this helps only at between the worklfow not at the time of start up because at the time of start up, originatorname is the currently logged in name of the user.

Let’s say, when you modify the task, then you get the Task Item and check for this property, so you will get the current User.

Here when i have used Item, then Item referce to the Item of the list which is being changed. List can be any list, then above is the way you can get the Current Logged in user.

Again the problem is it returns the entire string representing Id, Name and connected properties.

If you fetch this string and display in the Label, then it will get converted to hyperlink which will take you to the UserDisp.aspx.

so you need to tweak the string. Here is a way to tweak the string.

string[] strChar = { “ID=” };

string[] strChars = ModifiedbyUserName.Split(strChar, StringSplitOptions.None);

Int32 iUserID = Convert.ToInt32(strChars[1].Substring(0, strChars[1].IndexOf(“\””)));

string strAssignedTo = string.Empty;

for (int iCnt = 0; iCnt <= workflowProperties.Web.SiteUsers.Count – 1;iCnt++)
{
if (workflowProperties.Web.SiteUsers[iCnt].ID == iUserID)
{
strAssignedTo = workflowProperties.Web.SiteUsers[iCnt].Name;
break;
}
}

Install Application Templates OR any of .wsp template on Your Sharepoint Website using easy Batch file

::install.bat for WSP Template files

::Created by Vaibhav

:START

@ECHO OFF

SET /P INPUT=”Please enter the name of the .wsp file you want to deploy: “

ECHO.

ECHO Starting deployment of %INPUT%

:CHOICE

SET /P CHOICE=”Are you sure you want to continue? (Y or N): “

if %CHOICE%==Y goto YES

if %CHOICE%==y goto YES

if %CHOICE%==N goto NO

if %CHOICE%==n goto NO

ECHO %CHOICE% is not recognized. Please re-enter your answer.

goto CHOICE

:YES

ECHO Adding the Solution.

stsadm -o addsolution -filename %INPUT%

ECHO Executing service jobs.

stsadm -o execadmsvcjobs

ECHO Deploying the Solution.

stsadm -o deploysolution -name %INPUT% -immediate -allowGacDeployment -allowCasPolicies

ECHO Final Execution processing.

stsadm -o execadmsvcjobs

GOTO END

:NO

EXIT

:END

ECHO All Done!

:MORE

SET /P MORE=”Want to install another solution? (Y or N): “

if %MORE%==Y goto START

if %MORE%==y goto START

if %MORE%==N goto NO

if %MORE%==n goto NO

ECHO %CHOICE% is not recognized. Please re-enter your answer.

goto MORE

MOSS – Issue : Not able to activate MOSS Feature " Office SharePoint Server Publishing Infrastructure " : : Don’t Worry :Solution is here… Enjoy

If you are not able to activate “Office SharePoint Server Publishing Infrastructure” MOSS feature try following way:

1. Apply Sharepoint central administrator’s application pool to your webapplication from INETMGR temporary and try to activate freature “Office SharePoint Server Publishing Infrastructure”

OR

2. Stop and Restart “Windows Sharepoint Services Timer” from start ->run -> services.msc OR command line “net start “windows sharepoint services timer””

Let me know still if you are not able to activate feature “Office SharePoint Server Publishing Infrastructure”

Your comment would be appreciate.