Some of my best discoveries come from forum questions. Not that I'm the first one to discover it, mind you -- I'm well aware that my wheel has probably been invented countless times -- but my mind grows best when I have to research a solution for someone else's problem (maybe that's why I like consulting).
Today's question was a simple one: how do I remove the Edit Item and Workflows buttons from the ECB (Edit Control Block) in a particular list view?
If you're not familiar with the ECB for a list item, go to a list and select any list item; the List Item ECB will appear in the ribbon with commands like New Item, New Folder, etc.
Since a list view is just an aspx file, we can add some client-side code -- either directly in the page, or by way of the Content Editor Web Part.
Our code depends on jQuery, and looks like this:
$("td").hover(function() {
hideEditAndWorkflows();
});
$("input").hover(function() {
hideEditAndWorkflows();
});
function hideEditAndWorkflows() {
$("#Ribbon\\.ListItem\\.Workflow").css("display", "none");
$("#Ribbon\\.ListItem\\.Manage\\.EditProperties-Large").remove();
}
If you're a jQuery novice, you'll want to visit jQuery.com and get the latest version -- simply upload the necessary JS file to a library and add a script link to it in the page (there's a ton of reference material out there, including the excellent documentation at the jQuery site).
You may wonder at the backslashes we're using in the hideEditAndWorkflows function. Since these element IDs contain special characters (normally the dot denotes a class in CSS selectors), we have to escape them so that we can pass them properly through the system.
Once you have this code in place, you'll see the Edit and Workflows buttons for a moment after clicking the first list item on the page; after that, they should disappear and be completely unavailable to your average user.
Of course, client-side techniques like this will only go so far; if someone is technically adept and has the ability to perform these operations, he or she can open up the developer console and find the missing pieces. Be aware of this whenever you manipulate the SharePoint UI with JavaScript; while it's fun and easy, this technique should never be a substitute for proper governance.
Enjoy!
This happened to me in a client's WSS3 environment, but it seems to apply to 2010 as well. I had a site template created in one environment, but upon moving it to another, the Create Site operation resulted in a neat little error, complete with stack trace: "A duplicate name 'YourField' was found".
Upon investigating, I found that one of the lists in the newly-created site did indeed have duplicate fields. What was odd in this case was that the the list was based on a content type, and only one of the duplicates came from said content type. I deleted the extra fields, re-saved the template in the new environment, and created again -- only to have similar results.
Several forum posts recommend cutting open the template on your local machine, editing the XML, and rebuilding the solution CAB, but in my case, all it took was a quick "Delete list" followed by re-creating it and re-adding the content type. Save as template again, and this time -- instant site creation satisfaction.
In just over a week, I'll be speaking at SharePoint Saturday Houston. My topic will be Manipulating SharePoint with Client-Side JavaScript; we'll address client-side coding as a whole, look at the Client-Side Object Model, and then dive into a working sample app using the CSOM and jQuery. Come see how easy it is to develop complex solutions for SharePoint 2010 without ever opening Visual Studio.
The event is already chock-full of high-profile speakers and generous sponsors (and a few guys like me, with a session right after the huge gourmet lunch) -- and with just over 100 seats left, you'll want to register right away. Hope to see you there!
I almost didn't make it out alive. I followed the instructions in every piece of sample code and every forum post by someone who had no idea why their client OM code wasn't working, and my code still wouldn't get past the page load. I kept getting "'Type' is undefined" errors when sp.core.js tried to register the SP namespace.
As it turns out, you need the help of the default master page (or one like it) to get the object model loaded. Once I told my sample page to use the default master and modified everything accordingly, it hooked up and ran just fine.
Now I can finally get some work done.
SharePoint brings more power than ever to the end user. As usual, this is a double-edged sword. Its utility as a development platform is unmatched, but since many of the development tools are accessible from the browser UI, the dividing lines can get blurred.
Requirements-gathering (and subsequent documentation) can be tricky, and it's easy for us technical types to get confused about functional versus technical. Business users do not care about technical requirements and they should not have the opportunity to dictate them. If you have to explain a term (for example, "list" or "metadata column") to an end user, then most likely it does not belong under the heading of "functional requirements".
Functional requirements are about what the end user needs to accomplish. An excellent guide for this is the concept of the User Story, as employed in Agile
project management (we're kind of big on that here at Improving). The basic format is as follows:
As a _______ (what type of user),
I want _________
so that I can ___________
This
kind of requirement requires (heh) that you also define acceptance
criteria, by which you can determine that the
requirement has been fulfilled. The end result is that nobody can claim confusion about what you're trying to do, since the team has already agreed on the definition of "done".
Here at Improving Enterprises, we have a relatively new annual tradition of forming a moustache team for Movember. For those who are new to the concept, Movember is a month-long fundraising effort for men's cancer research. Each year, men (Mo Bros) from around the world join in sprouting a symbol of solidarity -- with the goal of eradicating men's cancers.
If you're able, please consider donating to this vital effort. You can read up on where the money goes and how it is spent, you can learn about the history of Movember, and of course you can see goofy pictures of me with incomplete facial hair (if you're into that sort of thing).
Thank you for your time, your money, or merely your attention. To show my gratitude, here's what the genetic recombination of Burt Reynolds and Derek Zoolander would look like if he had some sort of mental problem.
Typical SharePoint 2010 install. I had created all my domain users, set up my servers, and started installing the prerequisites. When the first box in the farm restarted and the preparation utility came up, I was asked for credentials and provided them, only to be rejected. At first I thought it was a standard "access denied" error, but a look at the fine print revealed the error titling this post.
I tried Run As Administrator; still no success.
Eventually I realized that I was signed in as the farm account, though I had not yet made it a local administrator. I right-clicked Computer Management, ran THAT with the proper credentials, made the farm account local admin, and all was right with the world.
Sometimes it's the little things.
Custom list. Custom New/Edit/View forms. Everything works perfectly... until the latest round of updates.
Now if you Bingle this error message, you'll get about twenty possible causes that run the gamut from a known bug, an unknown bug, and fixed/not fixed/hotfixed/workaround bug, all the way to corrupt content types and invalid form data.
In my case, however, it turned out to be a misspelled column name in a FormField control.
I'm just glad it's Friday.
Occasionally, you have a calendar full of all-day events and you don't want the calendar cluttered up with redundant timestamps. Here's a simple client-side script, suitable for framing (or a master page, or a content editor web part) that will cut down on the visual noise.
<script language="JavaScript">
var allDates = document.getElementsByTagName("nobr");
for(var i=0;i 0) {
allDates[i].innerHTML = allDates[i].innerHTML.replace("12:00 AM","");
}
}
</script>
This is a fairly common request, but the solution is often missing one crucial point. To use a custom New/Edit/Display form on your list, proceed as follows:
- Open your site in SharePoint Designer.
- Right-click the desired List (under the Lists node) and select Properties.
- Click the Supporting Files tab.
- Under Content type specific forms, select the Item content type (this is the part most people forget). If you are using a custom content type, select that; just make sure that the Folder type is NOT selected.
- Use the Browse button to select your custom forms in each category.
- Click OK.
More Posts
Next page »