0

Iam retrieving an item from my list with jsom in a script editor. i retrieve a field wich is the type of: user or group field. I want to display the group name i retrieve.

I tryied to parse to json, but the output is this then:

GroupName = {"$1Q_1":27,"$4A_1":"myGroup"}

How can i just get my name of the group: "myGroup" in this example?

1
  • there are methods to getting things parsed from json. how are you retrieving your group? Can you show your code?
    – Mike
    Apr 8 '14 at 15:16
4

You can use JSOM as:

var groupName  = oListItem.get_item("FieldName").get_lookupValue();
var groupId   = oListItem.get_item("FieldName").get_lookupId();
3
  • Thank you. i use the method, getByName. So i will go for get_lookupValue();. Thanks
    – Anders
    Apr 8 '14 at 15:24
  • If it works, please mark answer as correct to close the question.. Apr 8 '14 at 15:25
  • 1
    Yes, i had to wait 4 min before i could do that :)
    – Anders
    Apr 8 '14 at 15:29
0

yes help a lot function retrieveListItemsInclude() {

var clientContext = new SP.ClientContext.get_current();

var oList = clientContext.get_web().get_lists().getByTitle('ListName');
    alert('entra'+ oList);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><RowLimit>100</RowLimit></View>');
this.collListItem = oList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

function onQuerySucceeded(sender, args) {

var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();

 while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    listItemInfo += '\nID: ' + oListItem.get_id() + 
        '\nTitle: ' + oListItem.get_item('Title') + 
        '\nContact: ' + oListItem.get_item('Contact').get_lookupValue()+
         '\nDescription: ' + oListItem.get_item('Description') ; 

}
alert(listItemInfo.toString());

}

function onQueryFailed(sender, args) {

alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.