Wednesday, March 17, 2021

How to get permission of a SharePoint list for a user using RESTApi

 Use EffectiveBasePermissions to get permissions of the user on a list. Example:


/_api/web/lists/getbytitle('L2')/EffectiveBasePermissions

Note that this will give the permissions of the logged in user


function checkPermissions() {

    var call = jQuery.ajax({

        url: _spPageContextInfo.webAbsoluteUrl +

            "/_api/Web/effectiveBasePermissions",

        type: "GET",

        dataType: "json",

        headers: {

            Accept: "application/json;odata=verbose"

        }

    });


    call.done(function (data, textStatus, jqXHR) {

        var manageListsPerms = new SP.BasePermissions();

        manageListsPerms.initPropertiesFromJson(data.d.EffectiveBasePermissions);


        var manageLists = manageListsPerms.has(SP.PermissionKind.manageLists);


        var message = jQuery("#message");

        message.text("Manage Lists: " + manageLists);

    });

}

unable to install SP1 for my sharepoint designer, error “The expected version of the product was not found on the system”

Open Command Prompt use below command


C:\path_of_download_directory\spdsp2013-kb2817441-fullfile-x86-en-us.exe  PACKAGE.BYPASS.DE

Saturday, January 23, 2021

How do I retrieve the value of a lookup-field in a workflow?

 The workflow is looking for a Date and Time field, but lookups return text. You need to return the field as Lookup text.


Set Variable: lookupStart to Current Item:Lookup: Sprint Start Date, Return fields as Lookup Value (as Text)

Last Modified date for site collection?

 Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.Search.Query”)  


[String]$lastDate = "1/1/2018"


foreach($sc in $webapplication | Get-SPSite -Limit All)

{

    Write-Host $sc.Url -ForegroundColor Yellow


    $keywordQuery = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($sc)

    $keywordQuery.QueryText = "ContentClass:STS_ListItem AND LastModifiedTime>=$($lastDate) AND site:$($sc.Url)"

    $keywordQuery.RowLimit = 5;

    $searchExec = New-Object Microsoft.Office.Server.Search.Query.SearchExecutor

    $searchResults = $searchExec.ExecuteQuery($keywordQuery)


    If( 0 -eq $searchResults.Table.Count ){

        Write-Host "`tSite Collection $($sc.Url) is old" -ForegroundColor Red


}

Sort Order of a Lookup Column in SharePoint?

In this article ,  sort my lookup column based on a column 

 <script type="text/javascript" language="javascript">

    $().SPServices.SPFilterDropdown({ //This is the function that does the sorting.

        relationshipList: "Code", //This is the name of the lookup field in the form.

        relationshipListColumn: "Title", //This is the original column name from the lookup list as SharePoint knows it.

        relationshipListSortColumn: "Sortby"

        columnName: "Code", //This is the column name in the lookup list as it shows up.

        CAMLQuery: "<Neq><FieldRef Name='Title'/><Value Type='Text'></Value></Neq>", //This is the CAML Query if you want to select a specific set of items from the list. In this example it doesn't select items where the Title column is null. Note, the Title column is the original column name.

        debug: true

    });

</script>