Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CubeYogi/244885faf7949e2e003a49f7dc37efd8 to your computer and use it in GitHub Desktop.
Save CubeYogi/244885faf7949e2e003a49f7dc37efd8 to your computer and use it in GitHub Desktop.
//Validating Deal ID
if(deal_id != null)
{
//Getting Deal entry
deal_entry = zoho.crm.getRecordById("Deals",deal_id);
//Validating Deal entry
if(!deal_entry.isEmpty())
{
//Getting subform entry
associated_products = deal_entry.get("Product_Details");
//Validating subform map
if(!associated_products.isEmpty())
{
for each product in associated_products
{
//Getting Product Map
product_map = product.get("Product");
//Validating Product map
if(!product_map.isEmpty())
{
//Getting Product ID
product_id = product_map.get("id");
}
else
{
info "Product not associated";
}
}
//Validating Product ID
if(product_id != null && product_id.trim() != "")
{
//Getting Product entry
product_entry = zoho.crm.getRecordById("Products",product_id.toLong());
//Validating Product entry
if(!product_entry.isEmpty())
{
//Getting Product map
vendor_map = product.get("Vendor_Name");
//Validating Product map
if(!vendor_map.isEmpty())
{
//Creating product list
product_map.put("Vendor_Name", vendor_map);
prodcut_list = List();
prodcut_list.add(product_map);
//Getting vendor ID
vendor_id = vendor_map.get("id");
//Validating vendor ID
if(vendor_id != null && vendor_id.trim() != "")
{
//Getting vendor entry
vendor_entry = zoho.crm.getRecordById("Vendors",vendor_id.toLong());
//Validating vendor entry
if(!vendor_entry.isEmpty())
{
//Getting Vendor values
activity_date = vendor_entry.get("Activity_Date_Time");
vendor_mobile = vendor_entry.get("Vendor_Mobile");
vendor_email = vendor_entry.get("Vendor_Email");
update_map = Map();
//Putting Deal values
update_map.put("Activity_Date_Time",activity_date);
update_map.put("Vendor_Mobile",vendor_mobile);
update_map.put("Vendor_Email",vendor_email);
update_map.put("Vendor_Name",vendor_map);
update_map.put("Product_Name",product_id);
update_map.put("Product_Details",prodcut_list);
//Updating Deal
update_deal = zoho.crm.updateRecord("Deals",deal_id,update_map);
//Validating Deal response
if(!update_deal.isEmpty() && update_deal.containKey("status") && update_deal.get("status") == "error")
{
info "Error in updating Deal: " + update_deal;
}
else
{
info "Deal updated successfully";
}
}
else
{
info "Invalid Vendor entry";
}
}
else
{
info "Vendor ID is empty";
}
}
else
{
info "Vendor map is empty";
}
}
else
{
info "Product entry is empty";
}
}
else
{
info "Product ID is empty";
}
}
else
{
info "Subform is empty";
}
}
else
{
info "Deal entry is invalid";
}
}
else
{
info "Deal ID invalid";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment