Hi,
I am trying to fetch data from CRM to ZOHO Creator on User input of a fields like here "Accounts" using "SearchRecrods" task.
It is working fine for when every respective fields have values in CRM response but what I notice that when any of the fields in CRM of any record is blank then I got the below error it seems the response can't handle null value or it doesn't include this field in JSON list even. so script can't iterate the list. I tried to use "ifnull" but not working so.
for instance here you can see the variable "
Precio" can't update and I checked my CRM data there I have found there are some records in CRM for this account have blank so this is causing error.
Any anyone help me to fix it ? Thanks.
Here is the code and screenshots
- AccName = (input.Account).toString();
- contact_search = zoho.crm.searchRecords("CustomModule1", (("(Account Name|==|") + AccName) + ")", 1, 200);
- lin = "[" + contact_search + "]";
- lines = lin.toJSONList();
- for each line in lines
- {
-
- Warehouse_Receipts = (ifnull(line.getJSON("Warehouse Receipt"),"Not Found")).toString();
- Tracking_Numbers = (ifnull(line.getJSON("Tracking Number"),"Not Found")).toString();
- status_crm = (ifnull(line.getJSON("Status"),"Not Found")).toString();
- Precio = ( ifnull( line.getJSON("Precio de Venta x Kg") ,"0.0") ) .toDecimal();
- Peso = ( ifnull( line.getJSON("Peso en Paraguay (Kg)") ,"0.0") ).toDecimal();
- insert into On_Hand_Receipts
- [
- Added_User = zoho.loginuser
- Warehouse_Receipt = Warehouse_Receipts
- Tracking_Number = Tracking_Numbers
- Status = status_crm
- Weight = Peso
- Rate = Precio
- Account = input.Account
- Account_ID = input.Account_ID
- ]
- }
error :