Saturday, 27 January 2018

Anonymous user dispalyed “authentication required” log in pop-up on downloading files

Issue:

We have a simple task recently and that was to enable anonymous access in a site. So easy right? but sometimes it happens if you are not aware how it works, it takes lot of time. Here is same scenario. As we have set up anonymous access, client uploaded some files in library and put it links on a public page. It works fine if you have edit/ full control for site. But if you are anonymous user, you are asked to login.


Solution:

As I said earlier, if you know how it works, you will be able to solve it easily. Only you need to make sure that items are published with major version. If that is done, anonymous user will be able to download files without any issue.

If you search google, you will find that you need to provide "Open item" access to items. If above solution do not solve the issue, below are links to set up open access:





Friday, 15 December 2017

SharePoint 2013: Start Workflow with JavaScript Client Object Model


I have a request to start workflow using client side code. Below is the code that fix my issue:

Code sample:

<button type="button" onclick="Startworkflow(); return false;">Start Workflow</button>

<script src="https://code.jquery.com/jquery-1.7.1.min.js"></script>

<script>

function Startworkflow()

{ LoadScripts(); }

function LoadScripts(){

 SP.SOD.executeFunc("sp.js", "SP.ClientContext" , function(){

  SP.SOD.registerSod('sp.workflowservices.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.workflowservices.js'));

  SP.SOD.executeFunc('sp.workflowservices.js', "SP.WorkflowServices.WorkflowServicesManager", StartWorkflow);

 }) 

}





//Subscription id - Workflow subscription id

//list item id for which to start workflow. If site workflow, then send null for itemId

function StartWorkflow() {

 
   var subscriptionId = "f5fa7d47-52c0-48af-9728-acfad55731d2";

   var itemId = "";



   var ctx = SP.ClientContext.get_current();

   var web = ctx.get_web();

   var wfManager = new SP.WorkflowServices.WorkflowServicesManager(ctx, web);



   var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);

   ctx.load(subscription, 'PropertyDefinitions');

   ctx.executeQueryAsync(

       function (sender, args) {

           var params= new Object();

           //Find initiation data to be passed to workflow.

           var formData = subscription.get_propertyDefinitions()["FormData"];

           if (formData != null && formData != 'undefined' && formData != "") {

               var assocParams = formData.split(";#");

               for (var i = 0; i < assocParams.length; i++) {

                   params[assocParams[i]] = subscription.get_propertyDefinitions()[assocParams[i]];

               }

           }

           if (itemId) {

               wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, params);

           }

           else {

               wfManager.getWorkflowInstanceService().startWorkflow(subscription, params);

           }

           ctx.executeQueryAsync(

               function (sender, args) {

                   console.log("workflow start successfully");

               },

               function (sender, args) {
                 
                   alert('Failed to run workflow');

               }

           );

       },

       function (sender, args) {         

           alert('Failed to run workflow');

       }

   );

 }


As I have a site workflow, I am passing "itemId" parameter value null. You can pass your item id there.


Reference: http://ranaictiu-technicalblog.blogspot.in/2013/06/sharepoint-2013-start-workflow-with.html

Wednesday, 29 November 2017

Hide Social Media share button in Power BI embed code

Recently I was having a task for creating Power BI chart and embedding it in SharePoint. So It is easily available in google. But the tricky part is when you embed it in SharePoint as iframe, it will show share button at bottom of it. Our client do not want that.

Here is the bottom of iframe:








So what is solution:

We add a new div tag and append our iframe within that with little css touch. Below is code for same:

Code sample:

<style>
.iframebox{width:100%; float:left;position:relative; overflow:hidden}
.iframefooter{
    width: calc(100% - 40px);
background: #eaeaea; 
    /*background: #eaeaea;*/
    height: 31px;
    display: block;
    position: absolute;
    bottom: 5px;
    right:40px;
     z-index: 9999999999;
}
.blueborder{
    position: absolute;
    left: 0;
    bottom: 41px;
    height: 1px;
    background: rgb(36, 65, 153);
    z-index: 999999999999999999;
    width: 100%;
}
.ms-dlgContent {z-index: 99999999999 !important;}
</style>


<div class="iframebox">
<!--   Iframe code goes here -->
   <div class="blueborder">&nbsp;</div>
   <div class="iframefooter">
      <br>
      <br>
   <br></div>
</div>

Output:








Happy coding.

Saturday, 28 October 2017

How to get Site details in SharePoint Online?

These days, Microsoft is obsoleting code based solution from Office 365.  And these leads us to use JavaScript Object Model / Client Side Object Model to get data and add them in to content editor / script editor webpart to display data.

In this blog we will try to get current site title, web tile and any intermediate web title using CSOM. You can go deep down if you have further requirement for these objects.

Here is the basic function to get site details:

Sample code:

var currSiteTitle; // site collection details
var currWebTitle; // get sub site details
var parentWebTitle; // get any intermediate site details

$(document).ready(function() {
 
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
            getWebTitle();
     });
});

function getWebTitle() {

        var context = new SP.ClientContext.get_current();
        var site = context.get_site();
        var web = context.get_web();
        context.load(site);
        context.load(web);
        var parentInfo = web.get_parentWeb();  
context.load(parentInfo);
        context.executeQueryAsync(function() {

                console.log(site.get_title());
                console.log(site.get_url());
                console.log(web.get_title());
                console.log(web.get_url());
                console.log("Intermediate site value: " + parentInfo.get_title());

                currSiteTitle = site.get_title();
                currWebTitle = web.get_title();
                parentWebTitle = parentInfo.get_title();
            },
            function(sender, args) {
                console.log(args.get_message());
            }
        );
     }


Original Source:
  1. https://msdn.microsoft.com/en-us/library/office/jj246780.aspx
  2. https://msdn.microsoft.com/en-us/library/office/jj246877.aspx
  3. https://sharepoint.stackexchange.com/questions/175217/get-parent-web-of-a-subsite-using-jsom-in-sharepoint-2013

Tuesday, 3 October 2017

QueryString-error-The name request does not exist in the current context

After a long time, I was working on .net project. Basically I forget all basic things and on of them was how to use Query String. So here is blog for those who face issue same as me when user querystring and get error :

The name request does not exist in the current context

Below was code I was using:

if (!String.IsNullOrWhiteSpace(Convert.ToString(Request.QueryString["Source"])))
                {
                    Context.Response.Redirect(Convert.ToString(Request.QueryString["Source"]));
                }


Solution:

Solution is very easy. First, you need to add below reference in your code:

using System.Web;

This will allow you to use "HttpContext.Current" in your code. So your final solution should look like below:

if (HttpContext.Current != null && !String.IsNullOrWhiteSpace(Convert.ToString(HttpContext.Current.Request.QueryString["Source"])))
                {
                    Context.Response.Redirect(Convert.ToString(HttpContext.Current.Request.QueryString["Source"]));
                }

Monday, 11 September 2017

Cannot Read Property 'Showmodaldialog' of undefined

While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of undefined". Here is simple solution for that.

Code Sample:

function OpenDocsDialog(url1) {
    var options = {
        url: url1,
        dialogReturnValueCallback: myDialogCallback
    };
        SP.UI.ModalDialog.showModalDialog(options);  // this line gives error.
}


Solution :  We need to load "sp.js" file before calling above code. You can load "sp.js" file with below code sample:

ExecuteOrDelayUntilScriptLoaded(function () { //code }, "sp.js")

Full solutionExample :

function OpenDocsDialog(url1) {
    var options = {
        url: url1,
        dialogReturnValueCallback: myDialogCallback
    };

    ExecuteOrDelayUntilScriptLoaded(function () {
        SP.UI.ModalDialog.showModalDialog(options);
    }, "sp.js")
}

Wednesday, 12 July 2017

Activate Dynamics 365 in Office 365

Recently I have a POC task in Dynamics 365. And I spent some time as I din't know how to activate it. Follow below steps to activate dynamics 365:


  • Create Office 365 account (It must be E5 instance. E3 instance do not provide this functionality).
  • Once set up you will be able to see dynamics 365 installed.



  • But you can't start diging it out directly. There is bit configuration you need to add for activating it.
  • First click on admin icon to open admin center.



  • Now click on users.




  • In this you will see our user. select it.



  • In panel, click edit button on "Product licence".




  • Enable the Dynamics 365. Click save.



 


  • Now you will be able to see dynamics 365 in admin center. Click on it to open Dynamics365.




  • Select your required template. Click on complete set up.



  • Once setup, you will see Dynamics 365 Administration center.




Monday, 19 June 2017

0x8007000d the data is invalid when chaging a file name.

Recently I have downloaded a file which was a song. I was trying to update few property of it when I encountered below error:

0x8007000d the data is invalid



Resolution:

I googled this issus and found below blog:

https://answers.microsoft.com/en-us/windows/forum/windows_7-performance/0x8007000d-the-data-is-invalid-when-chaging-a-file/23301e0b-40c8-459d-975e-1abfc9a14758

It contains the solution. so why i need to write this blog? Because it is microsoft blog which may be not understandable to all or you need to do some extra steps your self in google to achieve it.

Below are the steps:

  • First we need to download a free software. You ca download it from below URL:
    URL: http://www.mp3tag.de/en/download.html
  • Once download, install it in your machine.
  • Open the tool. And click on file menu. and then click on change directory.
  • Select your source location.
  • It will show all files in right side pane.
  • Now as per the blog, we need to update ID3 version 2.4 to version 2.3. But when you select your file and check property pane in left side, you can see that tag property is not there.
  • Don't worry. Just click save and you will see the version is changed to 2.3.
  • Once this is done, you can update your settings in the tool as well as outside of the tool.
Hope this helps.



Thursday, 17 November 2016

3rd Level SharePoint SharePoint Navigation in Global Navigation

SharePoint 2013 only supports one level deep on drop downs. If you require the navigation to show 2nd level or 3rd level item under the 2nd level, global navigation will not allow it directly. The other approaches are you do managed navigation. But it has its own limitations listed here.

Resolution:

If you require the navigation to show 2nd level menu, you need to make a very minor tweak to the master page that the site is using.

  1. Using SharePoint Designer (SPD), open the master page being used by the site. In SPD, navigate to _catalogs/masterpage/yourmasterpage.html
  2.  In the master page file, search for SharePoint:AspMenu.
    1. You will more than likely have more than one instance of a menu control.  Look at the IDs to find the right navigation control for what you want to edit.  They are intelligently named, you will be able to sort out which one you need.   For default.master, look for ID=”TopNavigationMenu”.
  3. In the properties for the tag, find MaximumDynamicDisplayLevels=”1″.  Change the number from 1 to 2. (You need to level till you need navigation)
  4. Save the file and publish the master page (do this from SPD, Manage Content and Structure, or the Master Page Gallery).
  5. Refresh your browser.  Now when you mouse over menu, you should see another level of navigation pop up.
  6. If you have more than 2nd level of navigation, you have to first add them separately in global navigation first. Once you save your changes, edit top navigation, drag 2nd level navigation under 1st level navigation.
  7. If you have more than 2 level navigation, you won't be able to drag 3rd level navigation in 2nd level. For that you need to create your custom master page and do that process.

Limitations of Managed Navigation in SharePoint 2013

When SharePoint 2013 came out, one of the most promising features was the Managed Navigation. Configuring Managed Navigation in SharePoint 2013 is straightforward and provides great no-code solution. In this blog, I will walk through some of the major limitations and why you must avoid this solution.
 
1) For each site collection you need separate Term Set.
It is important to note that each term set can be associated with only one site collection at given time. In other words, it requires dedicated copy of term set for each site collection navigation. E.g. If you have 5 site collections, you must have 5 copies of same term set to use for 5 site collections navigation data.

If term set is already configured to use for Site Collection navigation and if you try to reuse same term set in another site collection, SharePoint will throw following warning “The selected term set is already used by another site” 

2) Managed Navigation can’t be secured or targeted to specific group.
 One of the great abilities of Structured Navigation was you can configure audience targeting or secure each menu item for specific audiences or SharePoint security groups. Unfortunately Managed Navigation can’t be secured or targeted to specific security group.

3) Manual Maintenance is still required to update global navigation menu items.
 As we discussed earlier, you must have 1 term set for each site collection. If you have more than 1 site collection, you must have more than 1 term set dedicated to each site collection. To ensure, all the site collection uses same navigation menu items, there are two options available in SharePoint 2013 for replicating term sets. Regardless of which approach you may take, it will require manual maintenance of reconfiguring term sets when you have changes in term set.

4) Managed Navigation doesn’t apply to Sub Sites automatically.
 This is another one of those mind-boggling limitations of Managed Navigation. If you have enabled Managed Navigation at the site collection and while creating sub sites, if you are planning to inherit parent navigation, Managed Navigation doesn’t apply to sub sites automatically. To resolve this peculiar issue, you must open Navigation page from sub site settings page and click “OK” for to take in effect.
   
5) Managed Navigation doesn’t provide open link in new tab.
Structural navigation provide you check box option to open link in new tab. This functionality is not provided in Managed navigation. Though you can overcome this issue with JavaScript patch, you need to put this patch in master page of each site collection to work.

6) Managed Navigation conflict with SharePoint js.
Managed navigation stops working if you explicitly load sp.core.js in your page. The sub level navigation stops populating. I don’t know the strange behavior of it as sp.core.js is SharePoint own js file. 

7) Managed Navigation displays additional home tab. 
This is not though limitation but its annoying for sure. Managed navigation displays first tab with site name additionally. You can't directly change it or hide it. The thing we need to do with it is mostly hide it with javascript and the bad thing is we need to put that in each and every masterpage.

SharePoint Server 2016 and 2019 Retirement: What IT Professionals Need to Know

Microsoft SharePoint Server 2016 and 2019 are reaching end of support on July 14, 2026. With the April 2026 feature retirement deadline now ...