0

When I look at the url at a given announcement list on e.g. a fresh team site, it is something like:

http://xyz/_layouts/listform.apsx?PageType=4&ListId={B3352....}&ID=4&ContentTypeID=0x010...

What I am trying is to link to a specific item in the list. Via SPServices I get the ID of the item easily - what I can't find is the ListId. I tried the GetList - operation but the "ID" which is given in that url is not the one I am looking for.

At which place is this ListId exposed?

EDIT: To make it more clear what I am coping with: The items in the announcement list all open with the URL I have provided above. What I can't find so far is the "ListId" value, in my actual case it is "{B3352...}". I already tried to get this ListId via SPServices GetList-operation but the value of the attribute "ID" from the returning XML shows a different ID {622C14...}. I looked at all the XML output and there is no value like the one I am looking for "{B3352...}" though I used the same code as already mentioned by yaron.

2 Answers 2

1

I found an error on my first approach and finally got the solution:

Unfortunately I didn't pass the webURL parameter on the GetListId function. So my result was nonesense.

The actual solution where to get the ListId from, I used the GetList-operation and parse for the Name-attribute:

var listId = $(xData.responseXML).find("List").attr("Name");

To add more detail to my overall topic, here is my final approach:

Final link structure

List

  • ListId - as mentioned above
  • ID - ID of the announcement item, got it through GetListItems $(this).attr("ows_ID")

Open Announcement in modal window

As users expect announcements to open in modal windows I added the following click event to my link element

onclick='NewItem2(event,this.href);return false;'
0

You can get List GUID by following this link

jquery-spservice-get-list-guid/

<script type="text/javascript" src="../ICTLibrary/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../ICTLibrary/jquery.SPServices-0.5.4.min.js"></script> 

<script type="text/javascript">
$("document").ready(function() { 

function GetListId(listName) {
var id = "";
$().SPServices({
operation: "GetList",
listName: listName,
async: false,
completefunc: function (xData, Status) {
id = $(xData.responseXML).find("List").attr("ID");
}
});
return id;
} 

var listid = GetListId("Plastic");
if(listid!=null)
{
$("#listid").append(listid);
}
else
{
$("#listid").append("list not found");
} 

});
</script>
<div id="listid" >Plastic list guid: </div>
3
  • I followed this example before, but neither the attribute "ID" nor any other one has the "ListId" value I am looking for.
    – curmudgeon
    Commented Sep 19, 2012 at 12:30
  • can you add code that your using ? Commented Sep 19, 2012 at 13:16
  • I added more detail in my question, thanks for looking :)
    – curmudgeon
    Commented Sep 19, 2012 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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