Have a text field i need to update from another module

Have a text field i need to update from another module

I have an accounts module wit some fields I need to interact with.

Carrier Name which is a lookup of a module called "Vendors"

Zone which is a lookup of a module called "Carrier Rate" 

Expected Tonnage which is a pick list

ZonaChargeRate which is a single line text field. (this is the field I need to update)

 

The Vendors module contains all detail about the carrier except a $ charge value per ton per km for delivery (this is proving to be too hard in a subform to get at)

The $ charge value per ton per km is now contained in the "Carrier Rate" module.

The "Carrier Rate" module has a lookup to the "Vendor" Module

It has a pick list for "Carrier Rate Name" which in turn creates the lookup for the "Zone" lookup field in the Account Module

it also has a series of fields that are named to match the expected tonnage pick list in the Account module - e.g. 0 -1.99T, 2.00 - 3.99T, 4.00 - 5.99T etc, etc (about 15 different fields one for each of the tonnage ranges a price might be needed)

The goal is to choose the carrier name, zone and expected tonnage in the Account module, and the workflow then auto populates the ZonalChargeRate text field in the Accounts module with the corresponding value that is contained in the matching field name of the Carrier Rate module that matches the expected tonnage chosen in the Accounts module.

 

I have this code below so far, it runs with no errors i can see the carrier name, the expected tonnage and the zone value from the Accounts module,  but the ZonalChargeRate is returning a null value.

so I'm assuming it cannot find the value I need, (at the moment i have hard coded the values of the expected tonnage (4.00 - 5.99T) is the field name to look for the value we need in the Carrier Rate module, ideally it would be good if the expected tonnage captured from the Accounts module could then be used as a variable that then looks up the required matching field of that name in the Carrier Rate Module and gets its value and puts it into the ZonalChargeRate field in the Accounts Module.

Hope someone can help, many thanks kevin


code below ......


rec = zoho.crm.getRecordById("Accounts",accountId.toLong());
car_Name = rec.get("Carrier_Name");
exp_ton = rec.get("Expected_Tonnage");
//zonalRate = rec.get("ZonalChargeRate");
zone = rec.get("Zone1");
info car_Name;
info exp_ton;
info zone;

mp = Map();
if(car_Name != null)
{
rate_rec = zoho.crm.searchRecords("Carrier_Rate","Name:equals:" + zone + ")");
if(exp_ton == "4.00 - 5.99T")
{
acc_rate = rate_rec.get("T3");
mp.put("ZonalChargeRate",acc_rate);
update = zoho.crm.updateRecord("Accounts",accountId.toLong(),mp);
info mp;
//info update;
}
if(exp_ton == "2.00 - 3.99T")
{
acc_rate = rate_rec.get("T2");
mp.put("ZonalChargeRate",acc_rate);
update = zoho.crm.updateRecord("Accounts",accountId.toLong(),mp);
info mp;
//info update;
}
}