Hi all, What is the best way of inserting a new customer into Kashflow? I am a classic ASP programmer and after finding out how to implement the API using ASP I am keen to use it, however I have hit upon the problem of how do you find the last customer in your 'Customer' records using say the 'Customer Code'. I have tried using GetCustomers and GetCustomer to read the records into a temporary array, read the last record in the array and increment by 1 to create my new unique 'Customer Code' So the question is if GetCustomer returns an array how is that array retrieved, so that you can iterate through them to find the last record. Cheers Rob Lucas
OK, I think I have found the solution. The Issue: The problem was with creating an instance of a new customer using the the basic ASP / API wrapper (_consumewebservice.asp) that Duane posted on his blog (see: http://blog.kashflow.com/2008/11/27/consume-soap-from-vbscript/). The Solution: Modify the wrapper and add two new functions that create the new instances Code: Function SOAP_OpenObj(byval strObjInstO) 'for opening a new object instance SOAP_REQUEST = SOAP_REQUEST + "<" + strObjInstO + ">" End Function Function SOAP_CloseObj(byval strObjInstC) 'for closing a new object instance SOAP_REQUEST = SOAP_REQUEST + "</" + strObjInstC + ">" End Function Then when you come to use it all you need to do is pass the instance you wish to create in the usual way. Code: SOAP_StartRequest "https://secure.kashflow.co.uk/api/service.asmx", "KashFlow", "InsertCustomer" SOAP_AddParameter "UserName", "xxxxxxxxx" SOAP_AddParameter "Password", "xxxxxxxxx" SOAP_OpenObj "custr" SOAP_AddParameter "Code", 12345 SOAP_AddParameter "Name", My Company SOAP_AddParameter "Contact", rob Lucas SOAP_AddParameter "Telephone", 01485 123456 SOAP_AddParameter "Mobile", 07770123456 SOAP_AddParameter "Fax", 01485 654321 SOAP_AddParameter "Email", info@domainname.co.uk SOAP_AddParameter "Address1", My Address 1 SOAP_AddParameter "Address2", My Address 2 SOAP_AddParameter "Address3", My Address 3 SOAP_AddParameter "Address4", My Address 4 SOAP_AddParameter "Postcode", PE30 1BB SOAP_CloseObj "custr" SOAP_SendRequest And to view the results Code: <html> <head> </head> <body> Status: <%=SOAP_GetResult("Status")%><br /> Status Details: <%=SOAP_GetResult("StatusDetail")%><br /> New Customer ID: <%=SOAP_GetResult("InsertCustomerResult")%><br /> </body> </html> If used in this way then the modified wrapper can also be used for inserting an Invoice (however not yet tested), all that remains is an instance of invoice line be added as a function to the wrapper. Hope this helps anyone who is in the same boat as I was... Happy Dayz!