Connecting zoho creator to zoho writer to send prefilled documents

Connecting zoho creator to zoho writer to send prefilled documents

i will paste the worflow below

// Get user's submitted data from the form
userSalary = input.Current_Salary;
userCIBIL = input.CIBIL_Score;
userEmail = input.Email;
userName = input.Name;
// You need to get the Document ID from the URL of your Zoho Writer template.
writerDocumentID = "3itvjfff75572b8204ff3b5ebba7605993cc5";
// writerConnection = "zoho_writer_connection;
// Fetch eligible bank products from the "Bank Details" form
eligibleProducts = Bank_Details[Minimum_Salary_Requirement <= userSalary && Minimum_CIBIL_Score_Requirement <= userCIBIL] sort by Interest_Rate asc;
// Create a list to track which banks have been added
addedBanks = List();
// Iterate through the eligible products
for each product in eligibleProducts
{
// Ensure we only recommend one product per bank and get the top 3 unique banks
if(addedBanks.size() < 3 && !addedBanks.contains(product.Bank_Name))
{
addedBanks.add(product.Bank_Name);
// This is the data for a single document merge.
mergeData = Map();
mergeData.put("User_Name",userName);
mergeData.put("User_Salary",userSalary);
mergeData.put("User_CIBIL",userCIBIL);
mergeData.put("Bank_Name",product.Bank_Name);
mergeData.put("Product_Name",product.Product_Name);
mergeData.put("Interest_Rate",product.Interest_Rate);
mergeData.put("Product_Description",product.Product_Description);
// This is the list of records for the merge task. It must be in a list with a "data" key.
recordsList = List();
recordsList.add(mergeData);
// Construct the values map as per the documentation.
valuesMap = Map();
valuesMap.put("merge_data",{"data":recordsList});
valuesMap.put("subject","Your Recommendation Document: " + product.Bank_Name);
// The document output format.
outputFormat = "pdf";
// The zoho.writer.mergeAndSend task sends an email for each record.
try
{
response = zoho.writer.mergeAndSend(writerDocumentID,outputFormat,userEmail,valuesMap,"zoho_writer_connection");
info "Response for " + product.Bank_Name + " : " + response;
}
catch (e)
{
info "Error sending document for " + product.Bank_Name + " - " + e.message;
}
}
}
// Send a different email if no banks are found at all.
if(addedBanks.size() == 0)
{
sendmail
[
from :zoho.adminuserid
to :userEmail
subject :"No Bank Recommendations Found"
message :"Dear " + userName + ",

We could not find any bank products that match your current salary and CIBIL score. Please check back later for new options.

Thank you."
]
}


    Access your files securely from anywhere









                          Zoho Developer Community




                                                • Desk Community Learning Series


                                                • Digest


                                                • Functions


                                                • Meetups


                                                • Kbase


                                                • Resources


                                                • Glossary


                                                • Desk Marketplace


                                                • MVP Corner


                                                • Word of the Day


                                                • Ask the Experts





                                                          Manage your brands on social media



                                                                Zoho TeamInbox Resources



                                                                    Zoho CRM Plus Resources

                                                                      Zoho Books Resources


                                                                        Zoho Subscriptions Resources

                                                                          Zoho Projects Resources


                                                                            Zoho Sprints Resources


                                                                              Qntrl Resources


                                                                                Zoho Creator Resources



                                                                                    Zoho CRM Resources

                                                                                    • CRM Community Learning Series

                                                                                      CRM Community Learning Series


                                                                                    • Kaizen

                                                                                      Kaizen

                                                                                    • Functions

                                                                                      Functions

                                                                                    • Meetups

                                                                                      Meetups

                                                                                    • Kbase

                                                                                      Kbase

                                                                                    • Resources

                                                                                      Resources

                                                                                    • Digest

                                                                                      Digest

                                                                                    • CRM Marketplace

                                                                                      CRM Marketplace

                                                                                    • MVP Corner

                                                                                      MVP Corner







                                                                                        Design. Discuss. Deliver.

                                                                                        Create visually engaging stories with Zoho Show.

                                                                                        Get Started Now


                                                                                          Zoho Show Resources

                                                                                            Zoho Writer

                                                                                            Get Started. Write Away!

                                                                                            Writer is a powerful online word processor, designed for collaborative work.

                                                                                              Zoho CRM コンテンツ






                                                                                                Nederlandse Hulpbronnen


                                                                                                    ご検討中の方