For each : Skip if field is missing
I've created a set up that will allow my users to import a spreadsheet and via a Function it will run through each row in the imported daa and update matching records in a chosen form/report. It's strange that Zoho Creator doesn't have this function as standard ... So I've created a page with a count of the imported records and a button to run the function.
What I am running into, is that if a specific field is blank in the import file then it will over write the existing data as blank. Fair enough. But it gets tiresome to have to match each column with the field every time you import. Is there any way to add into the for/each below that if the new data is blank then it will skip that update.
- void BulkUpdates.UpdateSuppliers()
{
//FETCH ALL THE DATA TO UPDATE FROM THE UPDATE SUPPLIERS FORM
for each varUpdateData in UpdateSuppliers[ID != 0]
{
//FETCH THE MATCHING FIELDS FROM THE MAIN SUPPLIERS FORM
varCurrentInfo = Suppliers[supplier_id = varUpdateData.up_suppliers_id];
//
//UPDATE THE FIELDS
// IF THE UPDATE FIELD IS BLANK IT CURRENTLY IT CLEARS THE MAIN FORM TOO
varCurrentInfo.supplier_name=varUpdateData.up_suppliers_name;
varCurrentInfo.supplier_type=varUpdateData.up_suppliers_type;
varCurrentInfo.supplier_company_type=varUpdateData.up_suppliers_company_type;
varCurrentInfo.supplier_status=varUpdateData.up_suppliers_status;
varCurrentInfo.supplier_vat_registered=varUpdateData.up_suppliers_vat_registered;
varCurrentInfo.supplier_vat_No=varUpdateData.up_suppliers_vat_no;
varCurrentInfo.supplier_terms=varUpdateData.up_suppliers_terms;
//Registered Address
varCurrentInfo.supplier_registered_office.address_line_1=varUpdateData.up_suppliers_registered_1;
varCurrentInfo.supplier_registered_office.address_line_2=varUpdateData.up_suppliers_registered_2;
varCurrentInfo.supplier_registered_office.district_city=varUpdateData.up_suppliers_registered_city;
varCurrentInfo.supplier_registered_office.state_province=varUpdateData.up_suppliers_registered_county;
varCurrentInfo.supplier_registered_office.postal_Code=varUpdateData.up_suppliers_registered_postcode;
varCurrentInfo.supplier_registered_office.country=varUpdateData.up_suppliers_registered_country;
//Trading Address
varCurrentInfo.supplier_trading_address.address_line_11=varUpdateData.up_suppliers_trading_1;
varCurrentInfo.supplier_trading_address.address_line_21=varUpdateData.up_suppliers_trading_2;
varCurrentInfo.supplier_trading_address.district_city1=varUpdateData.up_suppliers_trading_city;
varCurrentInfo.supplier_trading_address.state_province1=varUpdateData.up_suppliers_trading_county;
varCurrentInfo.supplier_trading_address.postal_Code1=varUpdateData.up_suppliers_registered_postcode;
varCurrentInfo.supplier_trading_address.country1=varUpdateData.up_suppliers_trading_country;
//
varCurrentInfo.supplier_contract_start_date=varUpdateData.up_suppliers_contract_start_date;
varCurrentInfo.supplier_contract_end_date=varUpdateData.up_suppliers_contract_end_date;
varCurrentInfo.supplier_contract_notice=varUpdateData.up_suppliers_contract_notice;
varCurrentInfo.supplier_year_end=varUpdateData.up_suppliers_year_end;
varCurrentInfo.supplier_review_month=varUpdateData.up_suppliers_review_month;
varCurrentInfo.supplier_performance_score=varUpdateData.up_suppliers_performance_score;
varCurrentInfo.supplier_authorised=varUpdateData.up_suppliers_authorised;
varCurrentInfo.supplier_notes=varUpdateData.Notes;
//Update the contract end alert date
if (varCurrentInfo.supplier_contract_end_date != null)
{
varCurrentInfo.supplier_contract_end_alert=varCurrentInfo.supplier_contract_end_date.addMonth(-1);
}
delete from UpdateSuppliers [ up_suppliers_id = varCurrentInfo.supplier_id ];
}
openUrl("https://creatorapp.zoho.eu/MyCompany/MyApp/#Page:update_menu"+"?target=iframe name","Same window");
}
If I try to add in some Ifs I get errors
- if ( varUpdateData.up_suppliers_name != null )
{
varCurrentInfo.supplier_name=varUpdateData.up_suppliers_name;
}
if ( varUpdateData.up_suppliers_vat_no != null )
{
varCurrentInfo.supplier_vat_No=varUpdateData.up_suppliers_vat_no;
}
Error Details - Execution Failed - Number of Statement executione limit excedded Line:(30)
Any suggestions ?