I am working with the Vendor module. I am validating a field using a function. I use the Vendor ID associated with the Vendor Name in a subsequent look up. The code I use is:
// First two lines are the standard reading of the record passed to the validate function
PurchaseOrderRecord = crmAPIRequest.toMap().get("record");
response = Map();
// Attempt to read from the passed record
PurchaseOrderVendorRecord = PurchaseOrderRecord.get("Vendor_Name");
PurchaseOrderVendorID = PurchaseOrderVendorRecord.get("id");
PurchaseOrderVendorName = PurchaseOrderVendorRecord.get("name");
// Using the returned Vendor ID to look up the corresponding record for other lookups
VendorRecord = zoho.crm.getRecordById("Vendors",PurchaseOrderVendorID);
This code works fine as a standalone function when I hard code a valid vendor ID and don't pass anything to the function.
When I use this as a function to validate a field, it breaks on the line where I attempt to '.get("id")'.
My questions are:
1. what does the record used in the validate which is passed to the function look like?
2. is there any way to capture / echo it? Since this is a validate function, the only passing back I've found is in '
response.put('status','error');
response.put('message',ErrorMessage);'
and that's limited to 100 characters. 'info' echoes can't be seen since you can't see the console when you're doing a validate AND I can't run in the dev window because I don't know what the record that is passed to the function looks like (question 1).
I am able to read from other modules when I have a valid ID. The trick in this case is finding the valid Vendor ID from the record passed to the function when it is used as a validate function.
Any help in surfacing what the record passed to the validate function has as its elements would be appreciated.