problem adding records to 2 related forms via 1 stateless form

problem adding records to 2 related forms via 1 stateless form

I submitted this to support yesterday but have not heard back yet so thought I would give it a try here.

I have a "Contacts" form and a "Clients" form. The Clients form has a "Billing Contact" lookup field which references the "ID" field of the Contacts form.

I am trying to use the OnClick event of a single stateless form to firstly add a Contact record and then add a related Client record using the ID returned by the first insert statement, but I am getting an error. When I click on the "View Error Details" link the only message displayed is:


Error details:
Error occured while executing on click script.
Error occured.
Here is the relevant part of my script:

  1.     // add contact
        Contact_ID = insert into Contacts
        [
        Owner = input.Owner
        Contact_Role = input.Contact_Role
        FName = input.Contact_FName
        LName = input.Contact_LName
        Email = input.Contact_Email
        Mobile = input.Contact_Mobile
        Phone = input.Contact_Phone
        ];
        //alert("Contact_ID = " + Contact_ID);

        // add client
        Client_ID = insert into Clients
        [
        Owner = input.Owner
        FName = input.Client_FName
        LName = input.Client_LName
        Gender = input.Client_Gender
        DOB = input.Client_DOB
        Referral_Source = input.Referral_Source
        Campaign = input.Campaign
        Referred_By = input.Referred_By
        Billing_Contact = Contact_ID
        ];

The contact record seems to be added ok as I am able to display a new "Contact_ID" value from the first insert statement in an alert. However, the client record insertion seem to be failing (which understandably causes the first transaction to be rolled back) and I don't know why.

I would appreciate any assistance.

Anton