Cannot get code to work with v2.mergeAndStore!

Cannot get code to work with v2.mergeAndStore!

Please can someone help me pass subform items into a repeating mail merge table row using v2.mergeAndStore?

I have a mail merge template created in Writer and stored in Workdrive. This template is referenced by a custom CRM function which merges all of the Deal information into a PDF order form. This has been working well for several years but now the mergeAndStore function is depreciated and I'm trying to update the code. 

I updated the function call to zoho.writer.v2.mergeAndStore and it fails.  I previously posted on here and was given a helpful pointer about the extra 'optional settings' variable which needed to be included, even if empty. I have since found through trial and error that it needs to have a map passed to it, even if there is nothing much in it. But is seems that this is not the whole picture. I get a very unhelpful R6000 error every time I try to run the function. 

So, after a very frustrating couple of days, I have stripped back all my code and isolated where the error is occurring. It is the subform, but only when there is more than one row.

The real world context is a list of items and prices being passed to a table in our mail merge document. The code I'm using for this is:

  1. if(graveDec.size() > 0)
  2. {
  3.     for each item10 in graveDec
  4.     {
  5.         priceMap = Map();  

  6.         itemInfo = item10.get("Description");
  7.         itemInfoAuto = item10.get("Item_Info_Auto");

  8.         if(itemInfoAuto != null)
  9.         {
  10.             itemInfoAuto2 = " (" + itemInfoAuto + ")";
  11.             itemInfoAuto1 = " (" + itemInfoAuto + ")";
  12.         }
  13.         else
  14.         {
  15.             itemInfoAuto1 = " - ";
  16.             itemInfoAuto2 = "";
  17.         }

  18.         if(itemInfo != null)
  19.         {
  20.             itemType = ifnull(item10.get("Product").get("name"), "");
  21.             productName = itemType + itemInfoAuto1 + itemInfo;
  22.         }
  23.         else
  24.         {
  25.             itemType = ifnull(item10.get("Product").get("name"), "");
  26.             productName = itemType + itemInfoAuto2;
  27.         }

  28.         priceMap.put("Subform_1.Description", productName);
  29.         priceMap.put("Subform_1.Price", ifnull(item10.get("Price"), "").toString());

  30.         subformList.add(priceMap);  
  31.     }
  32. }
  33. dataMap.put("Subform_1", subformList);
Subform_1 is a subform in the mail merge document and I have used the repeating row with description and price fields.

If it helps, when I info the dataMap, it comes out like this:

  1. DATAMAP= {"Delivery_To":"Cemetery Address","Cemetery":"Winster Cemetery","Cemetery_Address":"Elton Rd, Matlock, DE4 2DD","Ref_Number":"50251","Subform_1":[{"Subform_1.Description":"F 4 (Cherub Holding Flower Memorial Statue Marble Resin)\nASDFASDF","Subform_1.Price":"300"},{"Subform_1.Description":"BZ 789 (Photo Frame with Angels)","Subform_1.Price":"77"},{"Subform_1.Description":"Re-paint","Subform_1.Price":"7777"}]}
The Connection scopes are:

ZohoWriter.Merge.ALL

ZohoWriter.documentEditor.ALL
WorkDrive.files.ALL
WorkDrive.teamfolders.ALL

Can anyone help me?! Everything I read on the help documents suggests it should work fine and I'm about to bang my head on the desk if I look at it any more!