Friday, June 10, 2011

Change Add New Item Text of List View Webpart

When I came across this problem, I have found some solutions that uses javascript i.e. got the id of the “Add new item” link and change its text. But after sometime I have found another solution which uses SPD 2010. So, here is the solution:
  • Open Page in SharePoint Designer 2010
  • Open List and then choose the View on which you want to change the text.
  • Switch to Design mode and select List View web part.
  • Now You should see List View Tools on SharePoint designer ribbon, select Design from it.
  • There is a section called “Toolbar”, and an “option” dropdown is there, change options from “None” to any other option. Now You should see “Add New Item” link on Design View.
  • Select “Add New item” and click just after this link and wait for the vertical cursor to appear, this will cause the web part to Load on that page.  SharePoint Uses Web parts references on the pages and the data with the web part is rendered at runtime.
  • When cursor appears, just press any key so that it gets written on that page. Now Switch to code view.
  • Delete the key that you have pressed :)
  • Now look just before the cursor (where you have delete the pressed keys),  you may have the following code in front of you:
               <a class="ms-addnew" id="{$ID}"
                 href="{$Url}"
                 onclick="javascript:NewItem2(event, &quot;{$Url}&quot;);javascript:return false;"
                 target="_self">
                <xsl:value-of select="$AddNewText" />
              </a>
  • Remove “<xsl:value-of select="$AddNewText" />” and write your text that you want to display on the link.
  • Save the page.
View Page in your browser and verify the changes.
Happy Exploring SharePoint !!

Friday, June 3, 2011

Switching Infopath Views based on User Departments

During Sharepoint intranet portal development, i have experienced a problem that i need to display infopath forms differently to different departments (as a common Intranet portal have departments in it).I have noticed that the production environment haven't setup correctly i.e. User profiles were not synchronized by the sharepoint administrator and hence, the sharepoint user profiles doesn't have complete information of the users. 

I have overcome this problem by doing the following steps:
1- create security group for that particular dept
2- follow the steps of this link
http://blog.ianchivers.com/2011/01/using-sharepoint-usergroup-web-service.html 
and make a data connection "D1"
3- Now add a choice field in infopath form.
4- set its default value like this
boolean(@ID[@LoginName = concat(substring-before(@LoginName, "\"), "\", userName())])
where,
ID = D1 -> Data fields -> .... -> ID
LoginName -> D1 -> Data fields -> .... -> LoginName
boolean(), concat(), substring-before() and username() are the builtin infopath functions

Now On FormLoad Event, if choice field value equals your desired value, then switch the view...

Tuesday, March 22, 2011

Filter Sharepoint List View using Date Filter Web part


Couple of weeks back, I have a scenario in which I have to filter List views based on two datetime columns (date departure and date return). After searching a bit, I have found an excellent article by Mark Rackley on nothingbutsharepoint.com. It has enough guidelines for me to achieve my task. So, here is what I did to achieve the solution: 
  • I have created a custom List called “My Report” using sharepoint portal
  • Create a page in “Site Pages” Library called “Report View”.
  • Edit Page in Designer: Open that “Report View” Page in Sharepoint Designer. This page could be found in designer > Left Navigation Tool Pane > Site Pages. Open the page in design mode.
  •  Adding Data View To Page: Click on Data View (ribbon > Insert Tab) and choose “My Report”.
  • List Parameters: Select the List View, you then can view “List View Tools” in the ribbon, click on “Parameters”. This will cause a window to open.
  • Creating List Parameters: Click on “New Parameter” twice. Give proper names to the parameters. In my case, I have given them Names as “DateTo” and “DateFrom”.  From Parameter Source dropdown, select “Form”. Leave the other options, click OK.
  • Creating List Filter using parameters:  select List View, click on Filter (ribbon > List View Tools > Filter). You could see these fields i.e. Field Name, Comparision, Value. Now I have to view those items which are present inside that span that the user would select on the page, so my filter condition looks like {departure date > “DateFrom” and date return < “DateTo”}. So
  • select “departure date” in field name column, select “greater than” in comparison, select “[DateFrom]” in Value, select “And” in And/Or column. select “date return” in field name column, select “less than” in comparison, select “[DateTo]” in Value.
  • After setting the filter condition, save the page and close the designer.
  •   Go to the page using browser and open it in edit mode.
  •  Now Insert two date filter webparts (insert tab on the ribbon) on the page.
  • In Webpart connection, select “Get Parameter From”, a dialog would appear.
  • Choose “DateFrom” for one date picker and “DateTo” for second Date picker.
  • Save the page
That’s it! You are done. Happy Exploring Sharepoint…

Thursday, February 17, 2011

Hide Current View Dropdown from ribbon


In this post, I am describing that how to hide a dropdown from Sharepoint dialog ribbon where you have an infopath List form with multiple views.

Infopath List forms allows you to develop multiple views of the form.You can switch views depending upon your specific criteria or condition. When you create multiple views, a dropdown appear having the List of Views that you have made in the dialog ribbon i.e. when you initiate that form by adding new item to that list or by editing your existing item in the list, the infopath form will appear in sharepoint dialog in which there is a dropdown name “Current View” on the ribbon. 


Depending upon your scenario, you may want to hide this dropdown from users. So, here is the solution:
Open the form in infopath.
Select Page Design. Now you see the Views section (from where you have created the form views)


Select properties. A form will open with the selected view’s properties.
Uncheck the box labeled “show on the view menu when filling out this form”.


Publish the form and you are done.
Happy Exploring.

Monday, February 14, 2011

Manage Parent Child Relationship with infopath forms in Sharepoint 2010


During the past couple of weeks, I have been searching on how the parent child relationship could be managed in Sharepoint 2010, and have found two references on it:

Mark has explained very briefly how it could be done, but my scenario is a little bit different. Actaully I have infopath list forms and infopath forms does not allow to access Query string parameters of the pages on which they are placed. I have also tried to submit data from infopath 2010 list form to another list using web service (Lists.asmx) but I have failed (I am still need some help on this).
Ok, let’s talk about the solution that how we can get Query string parameter in infopath 2010 form:
  • Sharepoint 2010 have filter webparts that allows you to filter the page content by applying them, so I have use “Query string filter” webpart and set the properties of the Query string filter (Query string Parameter = <your parameter name>) .
  • Filter Webparts could also send the data to different webparts placed on the same page. It can be done by selecting the filter webpart and use “Connections” and send the Query string data to the infopath form webpart. One thing here, in the connection dialog, you would not see lookup columns i.e. if you have made a lookup column which points to the parent List then this column would not be visible in connection dialog, so you have to make a “single line of text” column in the child list and select it in connection dialog. You can hide this field from the List form and from the List Views.
  • Once you get the Query string parameter value in text field, you can copy it to the lookup column by using infopath rules.
Hope this information helps.