try {
// Fetch the BoM record linked to the Deal using its unique ID
bomRecord = zoho.creator.getRecordById("contact4247", "bom", "BoM", "input.dealId", "creatorconnection");
// Iterate over each subform and create entries in Material Orders
subforms = ["Sheet_Goods", "Lumber", "Edgebanding", "Hardware", "Finishing"];
for each subformName in subforms {
subformData = bomRecord.get(subformName);
for each product in subformData {
materialOrder = map();
materialOrder.put("Quantity", product.get("Quantity"));
materialOrder.put("Product_Name", product.get("Product_Name"));
materialOrder.put("SKU", product.get("SKU"));
materialOrder.put("Vendor", product.get("Vendor"));
materialOrder.put("Unit_Price", product.get("Unit_Price"));
createResp = zoho.crm.createRecord("CustomModule2", materialOrder);
if (createResp.get("status") == "error") {
// Logging the error instead of alert
info "Error creating Material Order in CRM: " + createResp.get("message");
}
}
}
// Add a return statement at the end
return "Success";
} catch(exception) {
// Logging the error
info "An error occurred: " + exception.toString();
return "An error occurred: " + exception.toString();
}
It seems like ChatGPT might be somewhat close, but I believe that since deluge is not as popular as other scripting languages it gets mixed up. Can someone help me out here?