1

I have a web part that I display a data view of one list say List A (below). This list has one column as a lookup which is already another existing list say List B.

Say, List A {Project Name, ID, Stage} and List B {Stage, Phase}

(rule: many stages can exist in one Phase)

Now, I'm required to display Phase based on the Stage. Meaning I just want to retrieve the phase the stage is in at the same data view I have.

Like this: value of ( Get ListB.Phase [where] Stage = "Stage1" )

Please can someone guide me. I would prefer to do it manually without using SPD 2007 menus.

I use html, javascript, xsl, ajax.

1
  • So you are on SharePoint 2007 right ? Jun 11, 2014 at 8:02

2 Answers 2

1

In case someone has same requirements (and restriction). As it seems that you are confident with js,ajax,html. I would go for list REST service. You can access this service via /_vti_bin/listdata.svc and to access a specific list you can send a GET with the following URI: /_vti_bin/listdata.svc/{listname} this will return all rows but since its an OData service you can make OData queries just by using URI for example in js you can have something like:

var stage = "stage1"
var uri = "/sitecollection/_vti_bin/listdata.svc/ListB()?$select=Phase&$filter=Stage eq '" + stage + "'"
$.getJSON(uri, function(data) {
    if (data.d.results) {
        // data.d.results is an array that contains 
        // all the items retrieved from the service based
        // on the query in URI you can write down your 
        // logic to do what you what with this data.
    }},
    function () {
        alert("Oops! something went wrong.");
});

For more information regarding List REST service in SharePoint following article is the best for a beginner: http://msdn.microsoft.com/en-us/library/office/fp142380(v=office.15).aspx

Note that you can use this service ONLY for authenticated users.

Alternative approach

In case you are familiar with CSOM (SharePoint Client Side Object Model) which is also accessible as JS libraries (JSOM), you can use it as well. Instead of providing an example I suggest you read the following article in MSDN, it is fairly easy to make and send a query and retrieve a list of items: http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx

I hope it helps someone ;)

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.