Showing posts with label SPServices. Show all posts
Showing posts with label SPServices. Show all posts

Saturday, January 23, 2021

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>

Wednesday, August 10, 2016

jQuery SPServices get list guid

$().SPServices({
operation: "GetList",
listName: "GSMHelp",
async: false,
completefunc: function (xData, Status) {
alert($(xData.responseXML).find("List").attr("ID"));
}
});

Friday, August 5, 2016

SharePoint 2013 get current user using JavaScript

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

<script type="text/javascript">
  var userid= _spPageContextInfo.userId;
  var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
  var requestHeaders = { "accept" : "application/json;odata=verbose" };
  $.ajax({
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError
  });

  function onSuccess(data, request){
    var loginName = data.d.Title;
    alert(loginName);
  }

  function onError(error) {
    alert("error");
  }
</script>

Friday, May 20, 2016

SharePoint Site Collection Administrators : Jquery

var user = SP.ClientContext.get_web().get_currentUser();

var value = user.get_isSiteAdmin ();
SPServices:

$().SPServices({
   operation: "GetUserInfo",
   userLoginName: $().SPServices.SPGetCurrentUser(),
   completefunc: function(xData, Status) {
   console.log$(xData.responseXML).find("User").attr("IsSiteAdmin"))
   }
});

how to get current sharePoint user department using javascript/spservices

<script src="/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>  
<script src="/Scripts/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>  
<script language="javascript" type="text/javascript" src="/Scripts/jquery.SPServices-0.7.2.min.js"></script>

<script language="javascript" type="text/javascript" src="/Scripts/sputility.min.js"></script>


<script type="text/javascript">  

$(document).ready(function() {  
    // get the title of current user  
    var UserName= $().SPServices.SPGetCurrentUser({  
    fieldName: "Title",  
   debug: false  
});  
// get department of current user
var userDepartment = $().SPServices.SPGetCurrentUser({
   fieldName: "Department"
   });
   




});  

</script>