Saturday, 17 December 2016

How to refresh the page after closing dialog in SharePoint?

Below code help is to refresh the page after closing the dialog in SharePoint:

 var options = {
    url: 'https://sp2013dev/sites/dev/Shared%20Documents/Forms/EditForm.aspx?ID=9',
    title: 'My Title',
    allowMaximize: false,
    showClose: true,
    width: 400,
    height: 350,
    dialogReturnValueCallback: function(result){
        if (result == SP.UI.DialogResult.OK) {
            window.location.reload();
        }
        if (result == SP.UI.DialogResult.cancel) {
            //do nothing, modal was closed
        }
    }

  };  
   SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); 


When you click Save button in model dialog above code refresh the page. And if you click close/cancel it will do nothing and will return to parent page.

Hope this helps....

Reference:http://sharepoint.stackexchange.com/questions/202829/how-to-refresh-page-after-closing-dialog-form-sharepoint-2013

Advantages of Lookup column

Lookup column is field that takes value from the another list and display as a Choice column or Multi select List-Box depending upon the selection.

Below are the advantages of Look column over a Choice dropdown column:

  • The Look up column allows non-admin users to add new choices in dropdown by adding new values in source list
  • You can manage permission at source list per list item. Depending on permission lookup column will show/hide specific items to user based on permission
  • Look up field can be used to make relationship between two lists
  • We can create count related lookup column in source list, which is computed field that computes the number of items in the target list that point to the current item of source list. Here is article on the same.


Set All lists in SharePoint Site to open in dialog

Recently in one of the project I needed to set all list in site to open in dialog. As it was more than 40 lists it was tedious job to do one by one.

A quick search on google gave me below powershell command which helped me to achive the functionality.

$web = Get-SPWeb -Identity http://rootsite/subsite
foreach ($list in $web.Lists)  { $list.NavigateForFormsPages = $false; $list.Update(); }




where false indicates that the list form page is launched in a modal dialog.

Hope this helps

How to restore deleted OOB timer job in SharePoint?

The simple way which I found and worked in my case is, to running below PowerShell script.

The PowerShell script restores the deleted timer job,

$farm = Get-SPFarm  
$farm.TimerService.EnsureDefaultJobs()  
Reference: http://sharepoint.stackexchange.com/questions/137538/how-to-restore-deleted-oob-timer-job

Friday, 16 December 2016

How to add custom CSS file in SharePoint 2013 Team Site MasterPage

There are two different ways to add custom CSS file in Team Site. In both the options you will need to first add your Custom CSS file in document library which is accessible to all users. In below example I have uploaded my custome css file in Site Asset document library.

Option 1:

  • Activate publishing feature on site.
  • Go to Site Action --> Site Settings

















  • Go To Look and Feel and then click on Master Page


















  • Scroll Down and Expand Alternate CSS URL and then browse your CSS Path and Click OK








You can use this option if you have publishing feature enabled, but what if the publishing feature is not enabled and you don't want to enable publishing feature.

In this case you will need modify master page and this is our option 2.

Option 2

  • Open your SharePoint Website in SharePoint Designer 2013.
  • Edit your masterpage and in Head Section add below lines of code. This will add your Custom css file in master page
<!--SPM:<SharePoint:CssRegistration name="&lt;% $SPUrl:~SiteCollection/Style Library/Custom Style/CustomCSS.css %&gt;" runat="server" after="corev15.css"/>-->

This way you can add your Custom CSS file in your SharePoint site.
Related Posts Plugin for WordPress, Blogger...