Create a Task and Invoice all from same Form.

Create a Task and Invoice all from same Form.

I am creating an invoice from within creator. This part works fine when I create a stand-alone form. I would actually like to incorporate the invoice form in with my task form so that I can complete all info at the same time. I am attaching the create invoice code at the very end of the create task code but only the invoice gets created and sent to Zoho Invoice. How do I code this to create a task and invoice all from within the same form. I have attached my code below. As stated, only the invoice part is being create and not the task within creator. Thanks.

urlStr = "";
if (input.Task  !=  null)
{
    if (input.Task  !=  "")
    {
        urlStr = urlStr + "&details=" + input.Task;
    }
}
success message "Task added successfully";
if (((input.Date_Time  !=  null)  &&  (input.When_s_it_due  !=  "-Select"))  &&  (input.When_s_it_due  !=  "Later"))
{
    if (input.googleCalUrl  &&  !thisapp.IsHidePostSchedule(input.Who_s_Responsible))
    {
        googleurl = (thisapp.google.getGoogleUrl(input.Date_Time)) + urlStr;
        openUrl(googleurl, "new window");
    }
}
if (input.backUrl  !=  "")
{
    openUrl(input.backUrl + "&" + (zoho.currenttime.toLong()), "same window");
}
itemsList = List:Map();
itemsList.add({ "ItemName" : "Supplies", "ItemRate" : "75", "Quantity" : input.Supplies_75 });
itemsList.add({ "ItemName" : "Paint", "ItemRate" : "200", "Quantity" : input.Paint_200 });
itemsList.add({ "ItemName" : "Accessories", "ItemRate" : "100", "Quantity" : input.Accessories_100 });
if (input.Make_Invoice_Open)
{
    input.Invoice_Detail_Status = zoho.invoice.createinvoice({ "CustomerName" : input.Customer_Name, "Items" : itemsList });
}
else
{
    input.Invoice_Detail_Status = zoho.invoice.createdraft({ "CustomerName" : input.Customer_Name, "Items" : itemsList });
}