0

I have a text box that I'm trying to take the value from and pass it into a REST query as a filter parameter when the button is clicked. If I hard code a value into the REST query it retrieves the values as expected. If i try to pass the form field as a parameter, I get no results.

Form:

Lawson ID: <input type="text" id="LawsonID" >
<input type="button" value="Execute Query" onclick="LoadInfo();" >

REST Query:

"/_api/Web/Lists/GetByTitle('Lv%20Inquiries')/items?/_api/Web/Lists/GetByTitle('Lv%20Inquiries')/items?$select=Title,Co_x002d_worker_x0020_Last_x0020,Co_x002d_worker_x0020_First_x002,Status,Status_x0020_Reason,Leave_x0020__x0023_,First_x0020_Day_x0020_of_x0020_W,Initial_x0020_Call_x002f_Contact,Restrictions_x0020_and_x002f_or_&$filter=(Title eq + 'LawsonID' + )&$top=5000"

1 Answer 1

0

It looks like you expect the value of an element, based on ID, to be referable in a query, which doesn't make much sense, at least not to me. Instead you need to get the value from the input, and build the query. There are several ways to do this, here is one:

var lawsonId = document.getElementById('LawsonID').value;
var query = "/_api/Web/Lists/GetByTitle('Lv%20Inquiries')/items?/_api/Web/Lists/GetByTitle('Lv%20Inquiries')/items?$select=Title,Co_x002d_worker_x0020_Last_x0020,Co_x002d_worker_x0020_First_x002,Status,Status_x0020_Reason,Leave_x0020__x0023_,First_x0020_Day_x0020_of_x0020_W,Initial_x0020_Call_x002f_Contact,Restrictions_x0020_and_x002f_or_&$filter=(Title eq '" + lawsonId + "')&$top=5000"
1
  • perfect! This helped me solved my issue
    – Jason
    Commented Mar 28, 2015 at 21:10

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.