Issue getting a variable into my Select Query statement. I

Posted by Rollbase User on 12-Apr-2013 18:10

I have 2 tables Person and Employee. When adding a record to the employee object, after keying in the SSN, I want to run a Select Query on the Person object to find a matching SSN. if a matching SSN is found, I update the Employee record with several fields. The issue is dynamically setting the WHERE clause to recognize the variable. So I am sure this is something I am just missing. My code below works when I specify, the WHERE clause (123-12-3456) but I need that be set by the variable above called ssn which is set by an on Change of that field. function person() { var ssn = document.theForm.ssn.value; rbf_selectQuery("SELECT id,firstName,lastName,address1,address2,city,state,zip FROM person WHERE social_security_number = '123-12-3456'",1,my_callback); } function my_callback(values) { alert(values[0][0]); rbf_setFieldValue('R32867', values[0][0]); rbf_setFieldValue('firstName', values[0][1]); rbf_setFieldValue('lastName', values[0][2]); rbf_setFieldValue('address1', values[

All Replies

Posted by Admin on 12-Apr-2013 19:26

I think you can modify query above and append ssn variable instead of hard-coded string.



Is your SSN field encrypted? If yes, this query may not work.

Posted by Admin on 12-Apr-2013 20:51

Hi Adam,



Given the guidelines of Pavel

You may try this:





function person()

{

var ssn = document.theForm.ssn.value;

rbf_selectQuery("SELECT id,firstName,lastName,address1,address2,city,state,zip FROM person WHERE social_security_number = '"+ssn+"'",1,my_callback);

}



...

...

...





Hope this helps,

Piscoso Martin

Rollbase

Posted by Admin on 15-Apr-2013 13:03

Hi Martin, that did it, thank you.

This thread is closed