Override redirect using EditItemWithCheckoutAlert

On an edit item link, you want to perform some operation and redirect to a page of your choice, write a small script on your page and override the EditItemWithCheckoutAlert function.
So when you click on the edit link, the EditForm.aspx opens.


This allows you to modify the fields and delete the list item. Once you perform your desired action, the dialog box is closed and you are redirected to previous view/default view. To override this, use the script below, modify it to suit your URL and put it in a CEWP/Script Editor WP on your page.




if (typeof(EditItemWithCheckoutAlert) != 'undefined')
{
var changed_EditItemWithCheckoutAlert = EditItemWithCheckoutAlert;
EditItemWithCheckoutAlert = function(evt, Url, bCheckout, bIsCheckedOutToLocal, strDocument, strhttpRoot, strCurrentUser, strCheckoutUser) {
changed_EditItemWithCheckoutAlert(evt, Url+'&Source=yourURL', bCheckout, bIsCheckedOutToLocal, strDocument, strhttpRoot, strCurrentUser, strCheckoutUser);
};
}


Converting InfoPath data connections to UDCX files

While working with InfoPath 2013 and SharePoint 2013 on a Windows 2012 platform, I came across an issue where I was not able to convert the InfoPath data connections into UDCX files. I was getting the error below:

The specified location does not exist or could not be opened. Choose a data connection library on a server running Microsoft SharePoint Server and specify a valid filename.


After some read through, I found out that for this to be able to work, I would need a Windows feature installed on the server. This feature is Desktop Experience. Once I enabled this from the Server Manager, and restarted the server, I got rid of this error. Files were then getting converted to UDCX and were published to the Data Connection library.



Hope this helps someone.

Disabling mobile site within SharePoint 2010

As we all know that SharePoint creates a very basic (ugly looking) default site for mobile devices. When opening the site from any mobile browser, it automatically directs the website to the respective mobile website which has /m appended to it.
My client did not wanted the default mobile site to open within mobile devices as it gives a very untidy look so they wanted to disable the redirect function. If you have similar issues, follow the steps below to disable the redirection.
  • Navigate to:
    • C:\inetpub\wwwroot\wss\VirtualDirectories\<yoursharepointsite>\App_Browsers\compat.browser
  • Locate
    • <userAgent match=”iPhone”&gt
  • Now under tag, locate
    • <capability name=”isMobileDevice”    value=”true”/>
  • Change this to false
  • Now for Android, repeat the same thing and set the ismobileDevice attribute to false.

No need to reset the iis or anything else. Just save the file and browse the site from iphone, you will see the desktop site opening.

Also, I noticed that if you create a backup copy of the file with any name within the folder, the site breaks and doesn’t render. So make changes within the file and copy it to some other location for a backup copy.

There is a MobilityRedirect feature within the SPWeb which can be disabled to prevent the redirection as well.
  • Disable-SPFeature –Identity MobilityRedirect –Url

Hope this helps someone

Deleting work item in TFS using Visual Studio 2010

As I was setting up TFS (Team Foundation Services) for my upcoming SharePoint project, I created few work items such as Tasks, Sprint Backlog, Bugs etc. also created custom fields and values within them. To test these items, I created a few test work items before moving it to live. Now, I wanted to get rid of the test work items I created before I could log live data in it. So here comes this post, where I would write on how we can delete work items from TFS. So, first of all, there is no simple tick and delete UI from Microsoft which does so. Microsoft recommends using command line to delete the work items. There are some free tools available through few of the sites, but I prefer deleting using command line. Follow the steps below:
  • Open Visual Studio Command Prompt by navigating to Start > All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools
  • Note down the IDs of the work items you want to remove from the TFS
  • Within the command prompt type the below syntax:
witadmin destroywi /collection /id:,,


Note: For noting down the IDs of the work items you can run a query that has ‘test’ in the Title field, provided you have entered test while your testing.

Resetting Sync databse within SharePoint

Resetting Sync database will delete the database completely with all the values in it.
I think one should reset the sync database as the last thing when all troubleshooting tricks provide no result. Only consider resetting when: 
  • Your import user profile connection is fetching details from AD but they cannot be seen on SharePoint
  • Similar scenario with export connections, so you want to push changes back to AD but you don’t see any changes on AD
  • You have modified settings on your FIM Client manually 

Here is a very nice article on resetting the sync database you should follow before considering a  reset:
PS: The User related information such as Profile Pictures, About Me etc. resides in Profile DB and the Social DB, these information will be safe as you do a reset of your Sync database

Using JQuery to hide SharePoint 2013 List Item fields

Hiding unnecessary fields in DispForm.aspx/EditFOrm.aspx is something most of us implement within our SharePoint implementations. Here is a quick way to achieve that using JQuery.
Hiding any List Item fields
So you have many fields in your NewForm.aspx but you want to hide some like in the screenshot. I want to hide the fields I haven’t underlined.

I will click on Edit Page, and add a Script  Editor webpart on the page. From the below script, just change the number in which your fields appear on the page using a 0 index. So to hide the first field, enter 0, second field – enter 1 and so on.


$(document).ready( function() {
$("TABLE.ms-formtable>TBODY>TR:eq(3)").css('display', 'none');
$("TABLE.ms-formtable>TBODY>TR:eq(7)").css('display', 'none');
$("TABLE.ms-formtable>TBODY>TR:eq()").css('display', 'none');
$("TABLE.ms-formtable>TBODY>TR:eq(9)").css('display', 'none');
$("TABLE.ms-formtable>TBODY>TR:eq(10)").css('display', 'none');
})

Also you can do some formatting on your page using Jquery, for example I am making the font as BOLD for the list item entries.

$(".ms-formbody").css("font-weight","bold");

Also,
I want to hide the information in the screenshot, you can add this line as well.

$(".ms-descriptiontext").css("display","none");

Hope this helps someone looking for a similar scenario.