How to get List of SharePoint Groups to which Current Users belongs using Javascript ?
How to get List of SharePoint Groups to which Current Users belongs using JavaScript? Not JSOM
Here is the code that worked for me:
var userid= _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + '/_api/web/CurrentUser/Groups?$select=Id,Title';
alert(requestUri);
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 s='';
for (var i = 0; i < data.d.results.length; i++)
s +=data.d.results[i].Title+'\n';
alert(s);
function onError(error) {
alert("error");
Similar Messages
-
How to get session vars of another or any current user
We all should know that the syntax session.varname will get or set a session variable for the one user currently making the request.
But can we write a method to get the session structure for ANY given user, when provided with a valid identifier like sessionID?
Don't everybody all yell at once now.Ah HA! I knew there was a way, it was just a matter of not knowing the magic phrase to search for (kinda like learning ActionScript).
Plain web service calls work just fine, but when my Flex app makes a Remote Object call to a cfc, my ColdFusion API always triggers onSessionStart, and has no apparent knowledge of the session variables that are already there for this Flex user (like the ones authorizing access to the API).
I figured the fix was to provide the sessionID in my initial LogIn method, keep that on the Flex side, then pass it back in the RO call - where sessionTracker could dig up the needed info?
Or my RO setup is just missconfigured? -
I want to get List of all active sessions in current system
Hi experts
How to get list of all active sessions in current system in any internal table along with details.
A sample code wud be helpful
Thanks in advance.try this code it might help u.
Below report execution gets the active Session list to ABAP memory
submit rsm04000_alv and return exporting list to memory.
refresh: gt_listobj.
Below FM get the List output from ABAP memory to gt_listobj in HEX
call function 'LIST_FROM_MEMORY'
tables
listobject = gt_listobj
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0. " Executed successfully ?
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
This FM converts ITAB gt_listobj from HEX to ASCII
call function 'LIST_TO_ASCI'
tables
listasci = it_list
listobject = gt_listobj
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
if sy-subrc <> 0. " Executed successfully ?
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
This Shows the output in List format on screen
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_structure_name = 'line'
tables
t_outtab = it_list
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0. " Executed successfully ?
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. -
How to add users from person or group field in a sharepoint list to sharepoint group
Hi,
How to add users(single or multiple) from person or group field in a sharepoint list to sharepoint group programmatically?
Any suggestions would be appreciated.
Thank you,
AA.Hello,
Use SPGroup.AddUser() method to add user in group. I have just written sample code in notepad so it is not tested:
SPSecurity.RunWithElevatedPrivileges(delegate()
using(SPSite Site = new SPSite(SPContext.Current.Site.Url))
Using(SPWeb Web = Site.OpenWeb())
SPList list = web.Lists["ListName"];
SPQuery query=new SPQuery ();
query.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Test</Value></Eq></Where>";
SPListItemCollection items = list.GetItems(query);
if(items.Count > 0)
foreach(SPListItem item in items)
//Get USers from person or group column
SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString());
SPGroup spGroup = spSite.RootWeb.Groups[groupName];//group name
if (users.Count != 0)
bool isUserInGroup = false;
foreach (SPFieldUserValue user in users)
foreach (SPUser item in spGroup.Users)
string itemUserName = item.LoginName;
string UserName = user.User.LoginName;
if (itemUserName == UserName)
isUserInGroup = true;
break;
if (!isUserInGroup)
spGroup.AddUser(user.User);
The above code will query list item and then get users from "Users" column. Now it will check whetehr user is already in group not, if not then add user in group.
http://rajanijilla.blogspot.sg/2012/09/add-users-to-group-programmatically.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
How to get list data and bind to data table or Grid view in share point 2010 using j query
hi,
How to bind list data in to data table or grid view using Sp Services.
How to use sp services in share point 2010 lists and document libraryHi, You can use List service, SPServices and JQuery to get your requiement done-
See here for an sample implementation -
http://sympmarc.com/2013/02/26/spservices-stories-10-jqgrid-implementation-using-spservices-in-sharepoint/
http://www.codeproject.com/Articles/343934/jqGrid-Implementation-using-SpServices-in-SharePoi
Mark (creator of SPServices) has some good documentation on how to use SPServices-
http://spservices.codeplex.com/wikipage?title=%24().SPServices
SPServices Stories #7 – Example Uses of SPServices, JavaScript and SharePoint
http://sympmarc.com/2013/02/15/spservices-stories-7-example-uses-of-spservices-javascript-and-sharepoint/
Hope this helps!
Ram - SharePoint Architect
Blog - SharePointDeveloper.in
Please vote or mark your question answered, if my reply helps you -
How to get list name through javascript?
Hi,
I wrote javascript for getting list items but here I'm hard coded list name as "Projects"(my list name). How can I get list name automatically with out hard coding,
Appreciate if anyone help.
Thank you.
function DoLogicalDelete()
var clientContext = null;
var oList = null;
var oListItem = null;
// var lstItmIsDeleted = null;
var itmID = getQuerystring('ID');
clientContext = SP.ClientContext.get_current();
oList = clientContext.get_web().get_lists().getByTitle('Projects');
// var oListItemID = SP.ListOperation.Selection.getSelectedItems(clientContext);
oListItem = oList.getItemById(itmID); // getting ID
clientContext.load(oListItem,"Title", "IsDeleted"); // load items to oListItem
oListItem.set_item('IsDeleted', true);
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));Not sure on which context you are executing the code. If you executing this from the list form and trying to get the current list, then you may need to get the list name from the breadcrumb/list title field. Refer to the following posts for more information
http://sharepoint.stackexchange.com/questions/39008/how-to-get-list-name-from-js-object-model-list-name-from-url-problem
http://itrob.be/sharepoint-get-all-lists-names-in-javascript-spservice-and-jquery/
--Cheers -
How to print/list all the groups/users present in Weblogic using Java code
Hi,
Weblogic version : 11.1.1.5
How to print/list all the groups/users present in Weblogic using Java code
I want to make a remote connection to Weblogic server and print all the users/groups present in it.
I have gone through the below mentioned site, but I cannot use the same approach since most of the API' are deprecated for example "weblogic.management.MBeanHome;"
http://weblogic-wonders.com/weblogic/2010/11/10/list-users-and-groups-in-weblogic-using-jmx/
Thanks in advance,
Edited by: 984107 on 05-Feb-2013 05:26
Edited by: 984107 on 05-Feb-2013 22:59see this http://www.techpaste.com/2012/06/managing-user-groups-wlst-scripts-weblogic/
Hope this helps. -
How to get list of software installed in a system
How to get list of softwares installed in a system?. should i use registry to get information or control panel?
is there any package available for this? how should i start with/
thanksHow to get list of softwares installed in a system?.Using native code, if at all.
should i use registry to get information or control panel?Linux has neither.
is there any package available for this? how should i start with/ Learn the Windows API or Google for some native tool. -
How to get list of docs for particulat billing type on plant wise
very urgent
is there any t-code, report to look thi
how to get list of billing docs grnerated for particulat billing type and if possible on plant wise also
very urgetnt
points to be rewarded
eagerly waitng from sap gurusDear chakri
As you may be aware, in VF05 you need to enter either Payer Code or Material Code and then based on the selection criteria, the report will generate. Please give the (ensure that this code is exist in billing document) Payer code and now select "Further sel.criteria" and DONT forget to enter the date in from column of "Billing docs.date". By default, there you can see one month date range.
Still if you get error message, please let me know the error message.
thanks
G. Lakshmipathi -
hi friends
i am trying to set peoples or groups field in sharepoint list form with current user login name
here my code
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
$(document).ready(function NewItemView () {
var currentUser;
if (SP.ClientContext != null) {
SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
else {
SP.SOD.executeFunc('sp.js', null, getCurrentUser);
function getCurrentUser() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
function onSuccessMethod(sender, args) {
var account = currentUser.get_loginName();
var accountEmail = currentUser.get_email();
var currentUserAccount = account.substring(account.indexOf("|") + 1);
SetAndResolvePeoplePicker("requester",account);
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
function SetAndResolvePeoplePicker(fieldName, userAccountName) {
var controlName = fieldName;
var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
peoplePickerEditor.val(userAccountName);
spPeoplePicker.AddUnresolvedUserFromEditor(true);
</script>
but it is not working
please help meHi,
According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
To set "peoples or groups" field with current user "login name”, you can use the below code:
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
function SetPickerValue(pickerid, key, dispval) {
var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
xml = xml + PreparePickerEntityXml(key, dispval);
xml = xml + '</Entities>';
EntityEditorCallback(xml, pickerid, true);
function PreparePickerEntityXml(key, dispval) {
return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
function GetCurrentUserAndInsertIntoUserField() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFailure));
function onSuccess(sender, args) {
SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
this._currentUser.get_title());
function onFaiure(sender, args) {
alert(args.get_message() + ' ' + args.get_stackTrace());
ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
</script>
More information:
http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
How to get list of drives present in local file system?
Hi all,
I want to show all drives and their contents using JTree.
Does anybody know how to get list of drives present in local file system?Thank you!
I have new question.
I want to disply size and file type. Can you give ur suggestion in order to do that?
I want to provide following using JTree
+ root <Dir> 50KB
- file1 <txt> 10KB
- file2 <bmp> 20KB
+ root2 <Dir> 200KB
-file1 <jpeg> 50KB
Is this possible?
Plz reply..........
bye -
How to get list of tables used in packages
Dear All
Can you pls tell me how to get list of tables used in packages
Regardsselect referenced_name
from user_dependencies
where name = 'your_package'
and referenced_type = 'TABLE'Regards,
Rob. -
How to get list of file names from a directory?
How to get list of file names from a directory?
Please helpIn addition, this:
String filename = files;Should be this:
String filename = files;
That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized. -
How to get listed as a XMP partner?
Hi there
We have just released a major metadata/keywords update, to our Digital Asset Management solution, based on Adobes XMP format.
Does anybody know how to get listed on the XMP partner page: http://www.adobe.com/products/xmp/partners.html
Thanks,
Jesper
Filecamp.comHi Frank
Just wanted to make sure you got our company information:
Your full company name
Filecamp AG
A company representative (name, title)
Jesper Faurby, CEO, Filecamp AG
About the partner
Filecamp is a lightweight Digital Asset Management, Image Library, and Online Proofing solution. Filecamp provides a secure customer branded platform to organize, review, approve, and share digital assets. Subscribers are from all over the world - ranging from freelancers to large corporations, usually from within the creative/media industry.
The value of XMP technology
"Adobe's XMP technology enables Filecamp to read and write metadata for common file types. Our customers appreciate the embedded metadata which allows keywords and more, to "travel" along with the files across various products, vendors and platforms."
Logo
A 170x55 px version of the logo can be downloaded from here: https://files.filecamp.com/public/file/21xp-1cum8c4d
Many thanks for your help. Please let me know if you have any questions.
Ok?
Best regards
Jesper Faurby
www.filecamp.com
Media Asset Management, Image Library, Professional File Hosting & Online Proofing ... in one integrated, secure and cost-effective solution. -
How to get List Item attachments name without write any custom code or any database query?
Hi,
How to get List Items attachments name without write any custom code or any database query?You can get it from Rest,
There are 2 options,
1) create a 'Result Source' which has a search query for that List which has attachments
- Use rest query to get the 'Filename' , it will have the attachment file name
For example, if the result source id is : 73e6b573-abf8-4407-9e5f-8a85a4a95159 , then the query will be
http://[site URL]/_api/search/query?querytext='*'&selectproperties='Title,Path,FileExtension,SecondaryFileExtension,Filename'&sourceid='73e6b573-abf8-4407-9e5f-8a85a4a95159'&startrow=0&rowLimit=100
You can refine the query, be giving proper 'querytext'
2) Use the List rest api
For example if your list guid is :38d524a1-e95c-439f-befd-9ede6ecd242e
You can get he attachments for 1st item using this
http://[Site URL]/_api/lists(guid'38d524a1-e95c-439f-befd-9ede6ecd242e')/items(1)/AttachmentFiles
get2pallav
Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.
Maybe you are looking for
-
Split balance sheet report by different business types
Hi Expert, Recently, one of my entity with new business type required to setup and target live by May-2011. Currently, we are using profit center accounting for P&L report. With the new business type, they would like to split the balance sheet report
-
Employee Listing using a Cost Center Hierachy
Hi, I have been requested by a user to provide an employee listing from the headcount infocube in SAP BW which lists employees by cost center using an existing cost center hierarchy, but not showing them at the cost center hierarchy node levels. My e
-
USA Address Cleanse - invalid City Directory
Hi All, I am getting the following error while using USA Address Cleanse transform; 4772 3680 DQX-058306 5/22/2009 11:15:20 AM Transform <USA_AddressCleanse>: Global Address Transform: WRONG DIRECTORY. Invalid City directory..
-
Automatic posting of invoice(miro) against pending Good Receipt of Goods
Hi Gurus, We had pending Migos(good receipts)against which bill(miro) has to be done. Is there any Transaction code where we can book the bills(miro) on mass scale against pending gir. Reargds Rajesh K
-
Difference between F1 & F2 billing types
hi, can any body explain the difference between F1 & F2 Billing types regards balaji.t