In list A I have column test I'd and Testdepartment. Testdepartment is a look column to ListA Testdepartment is present in ListB

Values in the column are as below:

Test ID Test department

1 A

1 B

1 C

1 D

2 E

endPointUrl ="/_api/Web/Lists/GetByTitle ('List A')/Items?$select=Test I'd, Testdepart ment/Title&$expand=Testdepartment/I'd";

I am using the below code to extract the Test department value based on the test I'd

   Var len = data.d.results.length;
      Var x=data.d.results[i].Testdepartment.Title;

But the above code returns only the last element of the array i.e., D on selection of TestID as 1 .

I want the code to return all the Testdepartment associated with the Specific TestID so that I can put it as a filter for another endpointurl.

endPointUrl2="/_api/Web/Lists/GetByTitle ('List B')/Items?$select=Title, Testdepart &$filter=Title eq"+x;

The Testdepartment is getting overwritten in the for loop. Just create an array of x and store all the values of Testdepartment as below:

   Var len = data.d.results.length;
   var x = [];
  • How can I split the value of x .For ex Title eq 'A' or Title eq 'B' – Priyanka Apr 30 '19 at 7:01
  • You could simply use a foreach loop: 'x.forEach(function(title) { console.log(title); });' – Sohail Shaikh May 1 '19 at 15:47

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.