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]

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