Showing posts with label SharePoint Design. Show all posts
Showing posts with label SharePoint Design. Show all posts

Wednesday, August 31, 2011

SharePoint 2010 Ribbon Customization

http://makarandrkulkarni.blogspot.com/2010/01/sharepoint-2010-ribbon-customization_23.html

Friday, March 25, 2011

Hide List View Tool bar Items

function hideListViewToolbarItems()
{
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
var itm = doc[i];
if (itm.id.match('OpenInExplorer') != null)
{
var p = itm.parentNode;
p.removeChild(itm);
}

}
}

A few thoughts as to why it's not working...

1) Match for part of the text and leave off the "zz33_" as that part can be different for every page.

2) Don't delete the nodes, hide them

3) Make sure your code is loaded after the web part with the View dropdown (i.e. if using a Content Editor Web Part, move it under the list web part)

Reference:MSDN

Thursday, March 24, 2011

Add Web Parts to DispForm, EditForm or NewForm.aspx

One of the users of our SharePoint project asked if it was possible to show an “Item List” on the “View Item” page.

My first reaction was: “Of course it is, add a Web Part displaying the “Item List” to the page and we’re done”.

But when I browsed to the “View Item” page and clicked the “Site Actions” I noticed that there wasn’t an “Edit Page” option available. Strange, but after some -Googling- I found the following sollution:

  • Open IExplorer and navigate to your “View Item” page (DispForm.aspx)
  • Replace everything in the URL after “?ID=#“ with “&PageView=Shared&ToolPaneView=2″ (without the quotes of course) and press
After adding a Web Part to the page and saving it, the “Edit Page” option will be available the next time you click “Site Actions” on that Page.

Useful Parameters to date for WSS 3.0 and MOSS 2007

Back in the days of WSS v2 and SPS 2003, one could use some handy URL parameter passing to edit web pages and browse for or search web parts.

My three favorite parameters for WSS v2 and SPS2003 were:

To Correct or Remove Misbehaving Web Parts
http://server/default.aspx?Contents=1

To Open the Page in Web Part Design Mode
http://server/default.aspx?ToolPaneView=2

To Open the Search Web Part Zone
http://server/default.aspx?ToolPaneView=3

Now in WSS 3.0 and MOSS 2007 we have the much more practical approach of switching views. Enter the Site Actions Menu, using the menu options we can edit the page, browse to site settings, etc.. But what happens if the Site Actions menu is not visible on the page. Maybe it was missed in the look and feel or has been removed deliberately like I had to do recently for a client. Now why someone would need to remove it and how this can be achieved (in at least two ways) will be covered in a later post.

Here are my favorite parameters to date for WSS 3.0 and MOSS 2007:

To open the Design Bar - Useful for pages in the Pages Library
http://server/default.aspx?DisplayMode=Design

To turn on Web Part Zone Editing
http://server/default.aspx?ControlMode=Edit

Note: The Site Actions Menu is rights trimmed and that means not all users can see or use it. Users with limited access or read rights will not be able to make use of the URL\Query String parameters. The parameters are just an alternative to get to the editing\design controls rather then a security bypass.

Tuesday, November 16, 2010

Get Current Logged On user using JavaScript

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("GetCurrentLoggedOnUserName");
function GetCurrentLoggedOnUserName()
{
var Loginname = document.getElementById("zz8_Menu").innerHTML ;
var end = Loginname.indexOf("<");
var nameOnly = Loginname.substring(8, end);
alert(nameOnly);
}
</script>

Jquery In SharePoint page

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("GetAlert");

$(document).ready(function GetAlert() {
var thisUser = 'test';
alert(thisUser);
});

</script>

Wednesday, November 10, 2010

"Append changes to existing text" feature of a multi-line textbox

How to work around the "append changes to existing text" feature of a multi-line textbox

Tags:

I love to use the multi-line text field in a SharePoint list or library. It is great for things like comments, status updates, notes and any other type of data that might require several lines of text. This column type even has a really cool feature that allows you to “Append Changes to Existing Text”. This feature will store ALL the changes to the field and display a historical list on the Edit or View pages.

clip_image002

Pretty cool! Right? Not so fast. This feature has some annoying drawbacks as well.

The Downside

There are two major side effects to turning the “Append Changes…” feature on.

1. It records all updates even blanks. If you edit the list item and only make a change to any field other than the multi-line text field it will store a blank in the history.

clip_image004

2. It will not display the current text in a list view. You only see a link that reads “View Entries…”.

clip_image006

A Common Approach

A common way I have seen this issue tackled is by creating a XSLT data view in SharePoint Designer. I will not cover this approach in detail, but the basic steps are:

1. Create a new Web Part page.

2. Add the desired list web part to the page.

3. In SharePoint Designer convert the web part into an XSLT Data View.

clip_image008

I do not care for this solution because it only address one of my gripes. It does show the most recent value entered into the multi-line textbox (Issue #2), but if that entry happens to be blank (Issue #1) it will display that as well. See the pictures above. Test Entry 2 displays the text that was entered, but Test Entry 1 shows blank. I want it to retain all the changes I have made and in the list view only display the last text that was entered.

My Solution

My approach utilizes a custom workflow to check for changes, but before we create the workflow we need to make some changes to your list.

1. Add a second multi-line textbox column. Call this one “Current Status” and make sure that the “Append Changes..” option is set to NO. Also, ensure that the “add to default view” is not checked.

2. Mark the new column as hidden. (This will prevent it from showing up in the Add / Edit / View pages)

a. Go to List Settings >> Advanced Settings and make sure the “Allow management of content types?” is YES.

b. In the List Settings page click on the content type to access its settings page.

c. Under the Column section click on “Current Status”.

d. Change the Column Settings to Hidden (Will not appear in forms).

3. Change the default view to show the “Current Status” column in place of the “Status” column.

a. Under the List Settings go to the Views section and click on the default view.

b. Uncheck “Status” and check the box next to “Current Status”. (You can also change the column order if needed)

Now that the list is configured properly we can create the new workflow.

1. Open SharePoint Designer to the desired site and click File >> New >> Workflow.

2. Name the workflow “Update Current Status” and select our list.

3. In the workflow start options ensure that only the boxes for “when a new item is created” and “whenever an item is changed” are checked.

clip_image010

4. Click Next.

5. On the next screen click Variables.

6. Add a new string variable named vRegExp.

clip_image012

7. In the Step Name field rename “Step 1” to “Initialize Variable”.

8. Leave the Conditions section blank.

9. Under Actions select “Build Dynamic String”.

10. Set our newly created variable “vRegExp” to the string “

.+
” (no quotes and it is case sensitive).

clip_image014

11. On the right hand column click the link to “Add workflow step”.

12. In the Step Name field rename “Step 2” to “Update Status”.

13. Under Condition select “Compare Test fields”.

14. Set the condition to “If Status matches regular expression Variable: vRegExp”.

15. Under the Actions select “Set Field in Current Item”.

16. Set the action to “Set Current Status to Status”.

clip_image016

17. Click Finish and exit out of SharePoint Designer.

Now try and update your list items and see what happens. If you enter a status then it will show up in the list view. If you update the item and don’t enter a status then the list view retains the last entry.

Conclusion

This solution uses the Status field with it’s “Append Changes…” feature in the Add / Edit / View forms, and uses the Current Status field for the list view to display the most recent update. A custom workflow was created in SharePoint Designer to check when the Current Status field needed to be updated.

**NOTE: It can take a few seconds for the workflow to run and update the field

Wednesday, November 3, 2010

Create Update List Item to value of people/user field

Create Update List Item to value of people/user field


Resolution:
1. Install Windows SharePoint Services February Cumulative Update:
http://support.microsoft.com/kb/961750.

Workaround:
If you are unable to install the SharePoint February CU, then here is a workaround:
1. Create a string variable in the workflow, and call it UserID.
2. Add the workflow action "Set Workflow Variable". Set the UserID variable to whatever user type column you are interested in (example: "Created By").
3. Add the workflow action "Build Dynamic String". In the dynamic string dialog, type "-1;#" (without quotes). Then, click "Add Lookup" to the workflow variable UserID. Click OK.
4. Still on the build a dynamic string action, set the variable to store in as UserID.
5. Change the workflow action to use the variable UserID when updating or setting the Person or Group type field.
NOTE: the same workaround works for FBA (forms based authentication) providers, as well.



Reference :

http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/9410ed52-e68b-4f5f-8acf-1b90e01d8556/

In SharePoint Designer, use a Dynamic String on your Person or Group field to insert "-1;#" to the beginnning of the field. I'm guessing this is due to some sort of error that occurs when SP parses a Person/Group list

http://social.msdn.microsoft.com/Forums/en-IE/sharepointworkflow/thread/81ed5261-3b0e-4d9c-be32-35900bb841a6http://mohd-shamim.blogspot.com/2009/02/spd-workflow-error-updating-list-item.html

Search Text:Create New Item Workflow Fails If people/user field error updating list item.

Saturday, October 30, 2010

How to know logged in user information

<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getWebUserData, "sp.js");
var context = null;
var web = null;
var currentUser = null;
function getWebUserData() {
context = new SP.ClientContext.get_current();
web = context.get_web();
currentUser = web.get_currentUser();
currentUser.retrieve();
context.load(web);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));
}
function onSuccessMethod(sender, args) {
var userObject = web.get_currentUser();
alert('User name:' + userObject.get_title() + '\n Login Name:' + userObject.get_loginName());
}
function onFaiureMethod(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>

Retrieving the logged-in user of a sharepoint site using Java Script

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

   var Loginname = document.getElementById("zz9_Menu").innerHTML ;  

   var end = Loginname.indexOf("<");

   var nameOnly = Loginname.substring(8, end);

   alert(nameOnly);   

  </script>

Friday, October 29, 2010

Server Variables in the DataForm WebPart

Variable Description
ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAW Returns all headers in raw form
APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path
AUTH_PASSWORD Returns the value entered in the client’s authentication dialog
AUTH_TYPE The authentication method that the server uses to validate users
AUTH_USER Returns the raw authenticated user name
CERT_COOKIE Returns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUER Returns the issuer field of the client certificate
CERT_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZE Returns the number of bits in server certificate private key
CERT_SERIALNUMBER Returns the serial number field of the client certificate
CERT_SERVER_ISSUER Returns the issuer field of the server certificate
CERT_SERVER_SUBJECT Returns the subject field of the server certificate
CERT_SUBJECT Returns the subject field of the client certificate
CONTENT_LENGTH Returns the length of the content as sent by the client
CONTENT_TYPE Returns the data type of the content
GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server
HTTP_ Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENT Returns a string describing the browser that sent the request
HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key
HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate
HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate
INSTANCE_ID The ID for the IIS instance in text format
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request
LOCAL_ADDR Returns the server address on which the request came in
LOGON_USER Returns the Windows account that the user is logged into
PATH_INFO Returns extra path information as given by the client
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRING Returns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
REQUEST_METHOD Returns the method used to make the request
SCRIPT_NAME Returns a virtual path to the script being executed
SERVER_NAME Returns the server’s host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORT Returns the port number to which the request was sent
SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL