Wednesday, September 12, 2018

Fetch data from multiple lists using SPSITEDATAQUERY

I knew posting on SPSITEDATAQUERY to too old , But recently I came ac-crossed requirement to get data from multiple lists . But I am posting this to keep the query handy

SPSiteDataQuery query = new SPSiteDataQuery ();
  // Query all Web sites in this site collection.
               Query. Webs = "<Webs Scope=\"SiteCollection\">";

               //Ask for all lists created from the contacts template.
               Query. Lists = "<Lists ServerTemplate=\"105\" />";

               // Get the Title (Last Name) and First Name fields.
               query.ViewFields = "<FieldRef Name=\"Title\" />";
               query.ViewFields += "<FieldRef Name=\"FirstName\" Nullable=\"TRUE\"/>";

               DataTable results = web.GetSiteData (query); 

Manage cloud identities with Windows using PowerShell


Changing Password
Set-MsolUserPassword –UserPrincipalName siddiq.ali@mycompany.onmicrosoft.com –NewPassword Pa$$w0rd –ForceChangePassword $true


Importing bulk users in Office 365 using Powershell
$NewUsers = Import-Csv –path .\NewUsers.csv


Applying Strong Password to the users
Set-MsolUser –UserPrincipalName siddiq.ali@mycompany.onmicrosoft.com
–StrongPasswordRequired $true

Powershell to set password to get never expires
Get-MsolUser | Set-MsolUser –PasswordNeverExpires $true

Configure password expiration

Set-MsolUser –UserPrincipalName siddiqali.mohammad@mycompany.onmicrosoft.com
–PasswordNeverExpires $true

REST API to filter null values for SharePoint list items

I am working for SharePoint online and I came crossed to get sharepoint list items based on null values via OTB web-part. Using IE browser I came to knew that I finding no luck to crack it.

Solution:

1. Use @v1 parameter for your rest api
2. And append the caml query @v1using $select

http://mysharepointsite/_api/web/Lists/GetByTitle('Documents1')/GetItems(query=@v1)?@v1={"ViewXml":"<View><Query><Where><And><IsNull><FieldRef Name='Selection'/></IsNull><Eq><FieldRef Name='EmpNumber'><Value Type='Text'>51457270</Value></Eq></And></Where></Query></View>"}&$select=Title


Friday, August 25, 2017

Unable to edit web part in a page

One of my business user added the page in site pages and included web part in it


And tried to edit the web-part , But I found no luck in getting the options
  
Solution:
  1. Open Internet Explorer, select the Tools button , and then select Compatibility View settings.
  2. Under Add this website, enter the URL of the site you want to add to the list, and then select Add  
                                                           or
Else it should be Microsoft Product issue

Tuesday, August 22, 2017

Set the co-authoring Limit for Web-application


Add-PSSnapin Microsoft.SharePoint.PowerShell
$site = Get-SPSite -Identity https://yourwebapplicationURL        
$site.Url
$site.WebApplication.WebService.CoauthoringMaxAuthors=19
$site.WebApplication.WebService.Update()
$site.Dispose()
Write-Host $site.WebApplication.WebService.CoauthoringMaxAuthors

The main purpose of the co-authoring is to limit the users for editing the particular document in document library .If the document is editing by too many users then users looses the UI experiance instantly ,So we limit the users interaction with co-authoring

Thursday, July 20, 2017

Find SharePoint Correlation-ID with Powershell

Today when I entered into my machine , I was getting correlation ID . I don't know where my team members changed the location of Log files from Hive 15 folder .

Then I used below by opening SharePoint Powershell command as administrator to fetech the log files 

Step 1: Merge-SPLogFile -Path ".\error.log" -Correlation "Correlation-ID"
Step 2: dir *.log

Tuesday, June 20, 2017

Powershell to find total documents in Farm

Get-SPSite -Limit All | Get-SPWeb -Limit All | % { $_.Lists} | ? { $_ -is [Microsoft.SharePoint.SPDocumentLibrary] } | % { $total+= $_.ItemCount} ; $total

Count total documents from all document libraries of Site Collection using PowerShell


$site = New-Object Microsoft.Sharepoint.SPSite("https://site collection name or any site");  # Get spsite object
$body = "Site Collection Document Audit for $site`r`n"
foreach ($web in $site.AllWebs)
{
    $url = $web.Url;
    $body = $body + "Web: $url`r`n";
    $lists = $web.GetListsOfType(1);   #Get all document libraries;
    foreach($list in $lists)
    {
       
        $count = $list.Items.Count;
        $title = $list.Title
        $body = $body + "        -  $title :$count items.`r`n"
    }
    $body = $body + "`r`n";
    write-host $body
$web.Dispose();
}
$site.Dispose();

Monday, June 12, 2017

Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage 'DistributedLogonTokenCache

SharePoint 2013 / 2016  uses app-fabric to host couple of cache cluster in this process the services of App fabric might get stooped due to it's time line . Also need to rights

Solution 1 :  Start the App Fabric cahcing services in Services.msc and reset IIS

Solution 2: Extend the cache Settings with powershell

$set = Get-SPDistributedCacheClientSetting -ContainerType DistributedViewStateCache
$set.requestTimeout = “100” # normally it’s 20ms
$set.channelOpenTimeOut = “100” # normally it’s 20ms
# maybe change the other values too
Set-SPDistributedCacheClientSetting -ContainerType DistributedViewStateCache $set

Solutions 3: The server farm account, which is also referred to as the database access account, is used as the application pool identity for Central Administration

  • Membership in the WSS_ADMIN_WPG Windows security group for the SharePoint Foundation 2013 Timer service.
  • Membership in WSS_RESTRICTED_WPG for the Central Administration and Timer service application pools.
  • Membership in WSS_WPG for the Central Administration application pool.
Solution 4 : Use the commands to stop ,remove and start the distributed service

Stop-SPServiceInstance
Remove-SPDistributedCacheServiceInstance
Add-SPDistributedCacheServiceInstance

Friday, May 12, 2017

Windows Server AppFabric is not correctly configured.You Should uninstall Windows Server Appfabric and reinstall it using The SharePoint Products Preparation Tool.


Dear All,

While installing sharepoint 2013 & 2016 I have been facing annoying error which is below screenshot
72

We all knew that we it shows frustrated repeated error

Windows Server AppFabric is not correctly configured.You Should uninstall Windows Server Appfabric and reinstall it using The SharePoint Products Preparation Tool

I tried below 2 ways which helped me to solve the issue
Solution 1 : 

$SharePoint2013Path = "D:\Appl\SP"
Start-Process "$SharePoint2013Path\PrerequisiteInstaller.exe" /KB2671763:$SharePoint2013Path\PrerequisiteInstallerFiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe
Start-Process "$SharePoint2013Path\PrerequisiteInstaller.exe" /AppFabric:$SharePoint2013Path\PrerequisiteInstallerFiles\WindowsServerAppFabricSetup_x64.exe

Solution 2:
  • Move WindowsServerAppFabricSetup_x64.exe to drive C:/
  • Type the following command line in PowerShell.

    \WindowsServerAppFabricSetup_x64.exe /i CacheClient,CachingService,CacheAdmin /gac
     
     
                                    or
         .\WindowsServerAppFabricSetup_x64.exe /i /gac



Sunday, October 9, 2016

Get Login UserName fon Preload of SharePoint List "NewForm.aspx"

Step 1:  Downlaod SPServices.js latest files

Step 2: Place the J.s filed into Asset Libraries

Step 3 :Replace the url of the SP.Services to your Side from below yellow color highlighted url

Step 4: Change the first parameter Name which should be the column from "Title" to  your  list column name in the function
SetUserFieldValue("Title",loginName);

<script src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>

<script src="/SiteAssets/jquery.SPServices-2014.02.js" type="text/javascript"></script>


<script type="text/javascript">

$(document).ready(function () {

 var loginName= $().SPServices.SPGetCurrentUser();

SetUserFieldValue("Title",loginName);



function SetUserFieldValue(fieldName, userName) {

 var _PeoplePicker = $("div[title='" + fieldName + "']");

 var _PeoplePickerTopId = _PeoplePicker.attr('id');

 var _PeoplePickerEditer = $("input[title='" + fieldName + "']");

 _PeoplePickerEditer.val(userName);

 var _PeoplePickerOject = SPClientPeoplePicker.SPClientPeoplePickerDict[_PeoplePickerTopId];

 _PeoplePickerOject.AddUnresolvedUserFromEditor(true);

}

});
</script>

Wednesday, August 24, 2016

Tabs for SharePoint Lists and Document Library

As we knew there are Bootstrap,Jquery and Angular JS tabs which are not fine to use sharepoint list iframe. So we have wounder-full post from "Mr.Mark" in his blog on "Hillbillytabs" for sharepoint which is the below code


<!-- Reference the jQueryUI theme's stylesheet on the Google CDN. Here we're using the "Start" theme -->
<link  type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/start/jquery-ui.css" />
<!-- Reference jQuery on the Google CDN -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!-- Reference jQueryUI on the Google CDN -->
<script type="text/javascript" src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>

<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js"></script>

<script type="text/javascript">
     jQuery(document).ready(function($) {


        //Put 3 web parts in 3 different tabs
//        var webPartTitles = ["Web Part Title 1","Web Part Title 2","Web Part Title 3"];
//        HillbillyTabs(webPartTitles);

        //Create a Tab with Two Web Parts, and a second tab with one Web Part
//        var webPartTitles = ["Tab Title;#Web Part Title 1;#Web Part Title 2","Web Part Title 3"];
//        HillbillyTabs(webPartTitles);
   
        //Put all web parts (that have visible titles) on page that have into tabs
        HillbillyTabs();

    });


    function HillbillyTabs(webPartTitles)
    {
        if(webPartTitles == undefined)
        {
            var CEWPID = "";
            $("#tabsContainer").closest("div [id^='MSOZoneCell_WebPart']").find("span[id^='WebPartCaptionWPQ']").each(function()
            {
                CEWPID = $(this).attr("id");
            });

            var index = 0;
            $("span[id^='WebPartCaptionWPQ']").each(function()
            {
                if($(this).attr("id") != CEWPID)
                {
                    var title = $(this).prev("span").text();
                   
                    $("#HillbillyTabs").append('<li><a href="#Tab'+index+'" id="TabHead'+index+'" onclick="HillbillyTabClick(this.id);">'+
                        title+'</a></li>').after('<div id="Tab'+index+'"></div>');
                   
                    var webPart = $(this).prev("span").hide().closest("span").closest("[id^='MSOZoneCell_WebPart']");
                   
                    $("#Tab" + index).append((webPart));
                    index++;
                }
            });
        } else {
        for(index in webPartTitles)
            {
                var title = webPartTitles[index];
                var tabContent = title.split(";#");
                if (tabContent.length > 1)
                {
                    $("#HillbillyTabs").append('<li><a href="#Tab'+index+'" id="TabHead'+index+'" onclick="HillbillyTabClick(this.id);">'+
                        tabContent[0]+'</a></li>').after('<div id="Tab'+index+'"></div>');
               
                    for(i = 1; i < tabContent.length; i++)
                    {
                        $("span[id^='WebPartCaptionWPQ']").each(function()
                        {
                            $(this).prev("span:contains('"+tabContent[i]+"')").each(function()
                            {
                                 if ($(this).text() == tabContent[i]){
                                   
                                    var webPart = $(this).closest("span").closest("[id^='MSOZoneCell_WebPart']");
                                   
                                    $("#Tab" + index).append((webPart));
                                 }
                               
                            });
                        });
                    }
                }
                else
                {
                    $("span[id^='WebPartCaptionWPQ']").each(function()
                    {
                        $(this).prev("span:contains('"+title+"')").each(function()
                        {
                             if ($(this).text() == title){
                                $("#HillbillyTabs").append('<li><a href="#Tab'+index+'" id="TabHead'+index+'" onclick="HillbillyTabClick(this.id);">'+
                                    title+'</a></li>').after('<div id="Tab'+index+'"></div>');
                               
                                var webPart = $(this).hide().closest("span").closest("[id^='MSOZoneCell_WebPart']");
                               
                                $("#Tab" + index).append((webPart));
                             }
                           
                        });
                    });
                }
            }
        }
        $("#tabsContainer").tabs();
       
        ShowActiveTab();
   
    }
   
   
    function HillbillyTabClick(id)
    {
        $.cookie("ActiveTab",id,{ path: '/' });
    }
   
    function ShowActiveTab()
    {
        $("#" + $.cookie("ActiveTab")).click();
    }
   
</script>
<div id="tabsContainer"><ul id="HillbillyTabs"></ul></div>

Tuesday, June 14, 2016

Disable The Tabs in Infopath Forms



Go to Web Browser Option from the "Form Options of  "Info Tab" and uncheck the "Show Infopath Command in ribbon or Toolbar




Monday, June 6, 2016

sharepoint 2013 feed format not supported in IE




  1. Tools > Internet Options.
  2. Select the Content Tab
  3. Under Feeds and Web Slices, select Settings
  4. Under Advance section untick Turn on Feed reading view

Sunday, May 29, 2016

iframe removing scroll bars

<iframe frameborder="0" style="height: 1185px; overflow:scroll; width: 100%" src="site url" marginheight="1" marginwidth="1" name="cboxmain" id="cboxmain" seamless="seamless" scrolling="no" frameborder="0" allowtransparency="true"></iframe>

or

<style>
.foo {
  width: 1800px;
  height: 900px;
  overflow-y: hidden;
}
</style>
<iframe src="https://siddiq-sharepoint.blogspot.com/"
        class="foo"
        scrolling="no"
        seamless="seamless">
</iframe>

Thursday, May 19, 2016

Error: WebForms UnobtrusiveValidationMode Requires a ScriptResourceMapping For jQuery in .Net

Open the web config file and you see the below  information
<?xml version="1.0"?>
<configuration>
    <system.web>

      <compilation debug="true" targetFramework="4.5" />

      <httpRuntime targetFramework="4.5" />

    </system.web>

</configuration>
Now you need to add the tags after </system.web>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />

  </appSettings

And after adding the tags ,Now web.config shows below info
<?xml version="1.0"?>
<configuration>
    <system.web>

      <compilation debug="true" targetFramework="4.5" />

      <httpRuntime targetFramework="4.5" />

    </system.web>

  <appSettings>

    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />

  </appSettings>

</
configuration>

Wednesday, May 11, 2016

Hide Recent Tab in SP 2013 QucikLaunch


<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
});
</script>


</div>