Creating a new deal with specific layout and pipeline

Creating a new deal with specific layout and pipeline

I am trying to create a button which creates a new deal for a particular account. It needs to be assigned a specific layout and pipeline. It seems like it should be really simple but I've been struggling to get this to work all day, can anyone help?!

  1. string button.CreateTradeOrderRemoval(String acctId,String UserId)
  2. {
  3. acctDetails = zoho.crm.getRecordById("Accounts",acctId);

  4. // map layout in case the id on its own is the problem.
  5. map_layout = Map();
  6. map_layout.put("name","Removals");
  7. map_layout.put("id", 345246000029262650);

  8. // map fields for new deal
  9. mp = Map();
  10. mp.put("Deal_Name","New Removal Order");
  11. mp.put("Layout",map_layout);
  12. mp.put("Pipeline","Removals Pipeline");
  13. mp.put("Order_Type","Trade Order");
  14. mp.put("Delivery_To","Cemetery Address");
  15. mp.put("Account_Name",ifnull(acctDetails.get("Account_Name"),""));
  16. mp.put("Owner",UserId);
  17. create = zoho.crm.createRecord("Potentials",mp);
  18. newpotid = create.get("id");
  19. return "You have successfully created a new Removal Order for this Trade Customer";

  20. }