User/group info in Javascript
-
- Posts: 17
- Joined: Tue Dec 17, 2013
Without using the Group Editor (so javascript editor only), can I get the logged in User Information and User's Group information?
Or, if I have to use the Group Editor, can javascript functions be called in the user-defined roles?
Or, if I have to use the Group Editor, can javascript functions be called in the user-defined roles?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hello,
You can use Groups functionality and JavaScript together. For example, you can define unique JavaScript code for the form which is designed for the specific Group. Another option is to obtain SharePoint groups the current user belongs to via JavaScript but this approach requires deep knowledge in JavaScript and CSOM:
http://msdn.microsoft.com/en-us/library ... e.14).aspx
http://maulikdhorajia.blogspot.ru/2011/ ... users.html
You can use Groups functionality and JavaScript together. For example, you can define unique JavaScript code for the form which is designed for the specific Group. Another option is to obtain SharePoint groups the current user belongs to via JavaScript but this approach requires deep knowledge in JavaScript and CSOM:
http://msdn.microsoft.com/en-us/library ... e.14).aspx
http://maulikdhorajia.blogspot.ru/2011/ ... users.html
-
- Posts: 17
- Joined: Tue Dec 17, 2013
Yes, very good idea. This appears to work (combining groups with javascript)
-
- Posts: 17
- Joined: Tue Dec 17, 2013
Hello. I also want to obtain the currently logged in user's name. Do I need to import libraries to do this? Can SharePoint javascript be directly inputted into the Form Designer javascript window?
-
- Posts: 17
- Joined: Tue Dec 17, 2013
in fact what I wanted to do was using java script to get the Author or Editor
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hello,
I've described how to get the current user login and prepopulate a field with it in the following post:
http://spform.com/forms-designer- ... point-2010
Could you describe your case in more detail?
I've described how to get the current user login and prepopulate a field with it in the following post:
http://spform.com/forms-designer- ... point-2010
Could you describe your case in more detail?
-
- Posts: 17
- Joined: Tue Dec 17, 2013
Hello, your blog article comes close, and I think will suffice for my needs - thanks!
What I was referring to was on the form, in the button fields we have the text "Created at [Created] by [Author]
Last modified at [Modified] by [Editor]". How do I in javascript extract the Editor and Author fields?
What I was referring to was on the form, in the button fields we have the text "Created at [Created] by [Author]
Last modified at [Modified] by [Editor]". How do I in javascript extract the Editor and Author fields?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Here is a short sample for you. Place the following code into JS-editor of Forms Designer:
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(parseInt(GetUrlKeyValue('ID')));
ctx.load(item);
ctx.executeQueryAsync(function() {
alert('Author: ' +
item.get_item('Author').get_lookupId() +
' - ' +
item.get_item('Author').get_lookupValue() +
'\nEditor: ' +
item.get_item('Editor').get_lookupId() +
' - ' +
item.get_item('Editor').get_lookupValue());
});
}), "SP.js");
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests