update field in one table with data from another based on certain criteria

update field in one table with data from another based on certain criteria

Cant seem to get my script to work to pull data in a specific field in a table and update with that information based on certain criteria
This is the script on success of the form loading records based on a different forms data entry.

r = Client_Rate_Table[Company_Name == input.Company_Name];
if(input.Position  ==  "General Foreman")
{
input.Bill_Rate=r.General_Foreman;
input.OT_Bill_Rate=r.General_Foreman_OT_Rate;
}