Friday, July 27, 2018

List View Filter - Show only Today's Or Less than 7days items


If you want to filter only items that are less than 7 days old then you just use
Filter
  • Created
  • is greater than or equal to
  • [Today]-7
Note - the screenshot is incorrect.
New items - created in last 7 days


Tuesday, November 21, 2017

REST Query



Author/Title&$expand=Author/Id


https://mydomain.sharepoint.com/mysite/_api/web/lists/GetByTitle('MyList')/items?$filter=Column1 eq 1 AND Column2 eq 2 AND Column3 eq 3

SharePoint Crawl Errors and Resolution

ERROR No. 01
Failed to retrieve data from the External System: 'MethodInstance with Name 'AttachmentStream' on Entity (External Content Type) with Name 'SFDCArticle_CEntity' in Namespace '.BCS.Connector.SFDCArticle_C' failed unexpectedly. The failure occurred in method 'GetAttachments' defined in class 'SFDCArticle_CService' with the message 'Sequence contains no elements'.

Solution:-

When you get the LINQ Error "Sequence contains no elements", this is usually because you are using the First() or Single() command rather than FirstOrDefault() and SingleOrDefault().
https://stackoverflow.com/questions/1324199/sequence-contains-no-elements

ERROR No. 02
Failed to retrieve data from the External System: 'MethodInstance with Name 'ReadItem' on Entity (External Content Type) with Name 'SFDCArticle_CEntity' in Namespace '.BCS.Connector.SFDCArticle_C' failed unexpectedly. The failure occurred in method 'ReadItem' defined in class '.BCS.Connector.SFDCArticle_C.SFDCArticle_CService' with the message 'Object reference not set to an instance of an object.'.'

Solution:-
Empty File OR Recrawl

ERROR No. 03


Tuesday, October 24, 2017

How to create managed property using powershell in sharepoint admin

$searchapp = Get-SPEnterpriseSearchServiceApplication -Identity c7276513-625d-4921-a2df-09c02c6007e2
$category = Get-SPEnterpriseSearchMetadataCategory –Identity SharePoint -SearchApplication $searchapp
$crawledproperty = New-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $category -VariantType 0 -PropSet "00130329-0000-0130-c000-000000131346" -Name "FAST_DBFIND_CCR.FAMILY_ID" -IsNameEnum $false
$managedproperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name "FAMILYID" -Type 3 -FullTextQueriable $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name ACCOUNTNAME -Type 1 -FullTextQueri
able $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
New-SPEnterpriseSearchMetadataManagedProperty : A managed property of the same
name ("ACCOUNTNAME") already exists.
At line:1 char:20
+ $managedproperty = New-SPEnterpriseSearchMetadataManagedProperty
-SearchApplicat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidData: (Microsoft.Offic...ManagedProperty:
   NewSearchMetadataManagedProperty) [New-SPEnterpris...ManagedProperty], Inv
  alidNameException
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.NewSearchM
   etadataManagedProperty

PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty

New-SPEnterpriseSearchMetadataMapping : Cannot bind argument to parameter
'ManagedProperty' because it is null.
At line:1 char:86
+ ... anagedProperty $managedproperty -CrawledProperty $crawledproperty
+                    ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-SPEnterpriseSearchMetadata
   Mapping], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
   icrosoft.Office.Server.Search.Cmdlet.NewSearchMetadataMapping

PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "COMPANYNAME" -Type 1 -FullTextQue
riable $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1002



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "CREATEDATE" -Type 1 -FullTextQuer
iable $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1003



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "DBID" -Type 3 -FullTextQueriable
$true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1004



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "DOCENGINEER" -Type 3 -FullTextQue
riable $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1005



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "ENGINEER" -Type 3 -FullTextQueria
ble $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1006



PS C:\Users\SPDevServer> $managedproperty = New-SPEnterpriseSearchMetadataManage
dProperty -SearchApplication $searchapp -Name "FAMILYID" -Type 3 -FullTextQueria
ble $true -Queryable $true -Retrievable $true -SafeForAnonymous $true
PS C:\Users\SPDevServer> New-SPEnterpriseSearchMetadataMapping -SearchApplicatio
n $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty



CrawledPropset             : 00130329-0000-0130-c000-000000131346
CrawledPropertyName        : FAST_DBFIND_CCR.ACCOUNTNAME
CrawledPropertyVariantType : 0
ManagedPid                 : 1007



PS C:\Users\SPDevServer>

Thursday, July 20, 2017

SHARE Document WITH EXTERNAL USERS – SharePoint Online


Need to deactivate below feature to check-out and check-in

Limited-access user permission lockdown mode


When this feature is enabled, permissions for users in the "limited access" permissions level (such as Anonymous Users) are reduced, preventing access to Application Pages.


TO Send emails to distribution lists (DLs) using SharePoint - we Should enable security group

Issue : Library Contribute
When a document contributed to an email should be sent t

Solution : - we have already providing  in CC, but our SharePoint Utilities Send Email not resolving as it is shared mailboxes or distribution lists (DL).

Please follow below steps in order to send emails to a DL from SharePoint, the DL needs to be converted to a security group that is email enabled.

1.     Go to Exchange Management Console -> Recipient Configuration -> Distribution group.
2.     Right-click on the problem group (i.e. the DL or the security group) and choose properties.
3.     On the Mail Flow Settings tab, double click on Message Delivery Restrictions.
4.     Uncheck the check box “Require that all senders are authenticated”.


Once done, the DL’s id can easily be searched in SharePoint’s directory and emails can be sent to

Friday, February 17, 2017

Dynamic SiteURL & RestURL call with X-RequestDigest Sharepoint


siteUrl = _spPageContextInfo.webAbsoluteUrl;

var restUrlnew = siteUrl + "/_api/web/lists/getbytitle('" + priviewList + "')/items(" + itemid+ ")?$select=Downloads";
            $.ajax({
                url: restUrlnew,
                method: "GET",
       headers: { "Accept": "application/json; odata=verbose",
       "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
        },                
                async: false,
                success: function (data) {

Change DATE Format DDMMYYYY OR MMDDYY


Function to get DD MM YYYY  OR MMDDYY


function formattedDate(date) {
    var d = new Date(date || Date.now()),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
   year = d.getFullYear();
   if (month.length < 2) month = '0' + month;
   if (day.length < 2) day = '0' + day;
   return [day,month,year].join('/');
}

Updating Sp list onclick of download or Open button

On click of download and Open button in document preview



//onClick of open button
        $('.preview-template').on('click', '.open-test', function (ev) {
            //ev.preventDefault();          
            updateToDownloadDetails();
            //window.location.href=serviceURL;        
        });

        //ONCLICK OF download
        $('.preview-template').on('click', '.download-test', function (ev) {
            //ev.preventDefault();
            updateToDownloadDetails();
        });
       

--------------------------

function updateToDownloadDetails() {
    try {
        var DownloadDate = new Date();
        var DownloadBy = CurrentUserID;
        DownloadCount = 1;
        var itemID = rowID;
        var listItem = ["Title", downloadURL, DownloadDate, DownloadBy, DownloadCount, olistName];
        clientContext = new SP.ClientContext(siteUrl);
        oList = clientContext.get_web().get_lists().getByTitle(downloadListName);
        var itemCreateInfo = new SP.ListItemCreationInformation();
        oListItem = oList.addItem(itemCreateInfo);
        oListItem.set_item('Title', "New Title");
        oListItem.set_item('DocumentUrl', listItem[1]);
        oListItem.set_item('DownloadDate', listItem[2]);
        oListItem.set_item('DownloadBy', listItem[3]);
        oListItem.set_item('DownloadCount', listItem[4]);
        oListItem.set_item('SourceLibrary', listItem[5]);
        oListItem.update();
        clientContext.executeQueryAsync
       (
           Function.createDelegate(this, function () { onSucceededDownloadUpdates(olistName,rowID); }),
           Function.createDelegate(this, this.onSucceededDownloadUpdates(olistName,rowID))
       );  
      }
       
        catch (err) {
            console.log(err.message);
        }
        }

function onSucceededDownloadUpdates(priviewList,itemid) {
GetDownloadCount(priviewList,itemid)
    console.log('Item updated!');
}

function onFailedDownloadUpdates(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    return false;
}

function GetDownloadCount(olistName,itemid){
 try {
           var restUrlnew = siteUrl + "/_api/web/lists/getbytitle('" + olistName+ "')/items(" + itemid+ ")?$select=Downloads";
            $.ajax({
                url: restUrlnew,
                method: "GET",
       headers: { "Accept": "application/json; odata=verbose",
       "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
        },                
                async: false,
                success: function (data) {
                var count=data.d.Downloads;
                UpdateListData(olistName,itemid,count);
                     }, //succss function
                error: function (data) {
                    alert("error");
                }
            });
        }        
        catch (err) {
            console.log(err.message);
        }            
}

function UpdateListData(ListName,itemId,cntdownloads) {
    try{
        var oList = clientContext.get_web().get_lists().getByTitle(ListName);
        var oListItem = oList.getItemById(itemId);
        var Count;
        Count=cntdownloads+1;
        oListItem.set_item('Downloads', Count);
        oListItem.update();
        clientContext.load(oListItem);
        clientContext.executeQueryAsync
           (
               Function.createDelegate(this, function () { onQuerySucceededUpdateList(); }),
               Function.createDelegate(this, this.onQueryFailed)
           );
    }
    catch(err){
        console.log(err.message);
    }
}

function onQuerySucceededUpdateList() {
    console.log('Item updated!');
     location.reload(false);
}
---------------------




How to Deploy Your HTML Website on a Linux Server (Apache + SFTP)

Launching a simple HTML website on your own Linux server is easier than you might think. Whether you're sharing a static landing page or...