0

I'm making a JavaScript extension for form elements. The goal is to bind it to a lookup and react on change. Since I'm weak at webservices, I'm using SPServices.

var lookupFieldInternalName = "LookupOne";

$().SPServices({
    operation: "GetList",
    listName: "Spis",
    completefunc: function(xData, Status) {
        console.log(xData.responseText);
        $(xData.responseXML).find("Fields > Field[Name='" + lookupFieldInternalName + "']").each(function() { ... });
    }
});

Inside I want to make a query to the list with lookup values. But in the field I get the only thing I have is the lookup's list Guid.

How can I get the lookup list name to query it? Or, how to query a list when all I got is a Guid?

Please provide code examples.

2
  • Are you saying you don't know the lookup list name before hand? Dec 3 '14 at 13:29
  • Well, ofcourse I know what list is the source of lookup data, but that's not my goal :-) I try to make the extension generic for forms, so it bases on information that's provided by SPServices. And the only data I see is the list Guid. Dec 3 '14 at 13:40
1

You can use a GUID or the display name for the listName parameter in SPServices. Make sure you use the curly brackets in the GUID.

var lookupFieldInternalName = "LookupOne";

$().SPServices({
    operation: "GetList",
    listName: "{C1AA0A1F-8177-4D64-AC3F-FDCFB31EFCA5}",
    completefunc: function(xData, Status) {
        console.log(xData.responseText);
        $(xData.responseXML).find("Fields > Field[Name='" + lookupFieldInternalName + "']").each(function() { ... });
    }
});
1
  • I must've overlooked that when I was reading the documentation. Thank you :-) Dec 3 '14 at 13:51

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.