Using Deluge To Merge and Download Document and Attach to Deal

Using Deluge To Merge and Download Document and Attach to Deal

I have a custom function that currently lives inside Zoho CRM and is triggered via a workflow rule. The custom function takes information from a deal and creates a merged document (zoho writer functionality), and then attaches that merged document to the deal. In an effort to save our workflow rules limit, I wanted to migrate this custom function to "Zoho Flow." Unfortunately, when I create a custom function and copy and paste the code into the custom function in Zoho Flow, I get an error saying "zohowriter connection doesnot exists at line number 1. Resolve the errors and try again"

My "zohowriter" connection was created in Zoho CRM. I don't know if I have to create a different connection for Zoho Flow. Would greatly appreciate it if someone could help me figure out what I need to change for this to work through Zoho Flow.

For reference, I used this for instructions on the custom function and it DOES work if you do it from CRM: 

Here is the full code:

void testmvk(int potid, string xxxxx)
{
potinfo = zoho.crm.getRecordById("Deals",potid);
fields = zoho.writer.getMergeFields(xxxxx,"zohowriter").get("fields").distinct();
val = Collection();
for each  rec in fields
{
field = ifnull(potinfo.get(rec),"");
if(field.contains("{") && field.contains("id"))
{
val.insert(rec + ":" + field.get("name"));
}
else
{
val.insert(rec + ":" + field);
}
}
cmp = "{" + val.toString() + "}";
ddata = List();
ddata.add(cmp.toMap());
dmp = Map();
dmp.put("data",ddata);
mp = Map();
mp.put("merge_data",dmp);
file = zoho.writer.mergeAndDownload(xxxxx,"pdf",mp,"zohowriter");
update = zoho.crm.attachFile("Deals",potid,file);
}

    Zoho Marketing Automation
      Zoho Mail - CRM Integration

              Zoho Pagesense Resources

                Zoho SalesIQ Resources



                      Zoho TeamInbox Resources

                        Zoho DataPrep Resources



                          Zoho CRM Plus Resources

                            Zoho Books Resources


                              Zoho Subscriptions Resources

                                Zoho Desk Resources

                                  Zoho Projects Resources


                                    Zoho Sprints Resources


                                      Qntrl Resources


                                        Zoho Creator Resources


                                          Zoho WorkDrive Resources




                                              Zoho Campaigns Resources

                                                Zoho CRM Resources

                                                        Design. Discuss. Deliver.

                                                        Create visually engaging stories with Zoho Show.

                                                        Get Started Now