The “UpdateData” method is used to add, update or delete entries in LIME via Lime CRM Web Service. This method receives an XML document containing the entries that are to be added, updated or deleted. The method returns an XML document with information about each action taken with the entries. All records specified in the update document are created/updated/deleted inside a transaction.
The following example changes phone and e-mail address for two existing person entries.
<?xml version="1.0" encoding="utf-16" ?> <data> <person idperson="1001" phone="046-45 67 89" email="my-new-address@example.ab"/> <person idperson="1002" phone="046-56 78 90" email="yihaaa@example.ab"/> </data>
The following xml is returned and contains the transaction id of this operation.
<?xml version="1.0" encoding="UTF-16" ?> <xml transactionid="transactionid="2AC3F47F-4E0A-458C-9358-B49807B421A7""/>
If ID is excluded a new entry will be created instead. So always make sure to include the ID to clarify your intentions.
New entries are created by specifying a negative id for the entry. Note that if an id is excluded then a negative id will be automatically generated and a new entry will be created. The following example adds two new persons to an existing company with the entry ID “1001”. Note that the entry ID for the new persons are negative, which means that these are a new entries:
<?xml version="1.0" encoding="utf-16" ?> <data> <person idperson="-1" company="1001" name="Karl Pedal" nickname="Kalle" phone="046-44 55 66" cellphone="070-44 55 66" email="karl.pedal@example.ab" personcategory="Vice MD and a little of everything" /> <person idperson="-2" company="1001" name="Ulf" nickname="Tuffa Uffe" phone="046-44 55 66" cellphone="070-44 55 66" email="uffe@example.ab" personcategory="Consultant" /> </data>
Each id for a new record must be unique in the document. The following XML document is returned for the new entries:
<?xml version="1.0" encoding="UTF-16" ?> <?xml version="1.0" encoding="UTF-16" ?> <xml transactionid="4DADD418-C410-4E67-85D3-DE2B9ACED4A9"> <record table="person" idold="-1" idnew="46996001" /> <record table="person" idold="-2" idnew="46997001" /> </xml>
This document contains a node for each entry that was added. The node contains information about the table to which the entry was added, the entry ID specified in the data document and the entry ID allocated to the entry in the database.
If ID is excluded one will be generated for you and new entry created. This can be an issue when multiple entries are created because it can be difficult to map the generated IDs against the data you posted. Always include ID to clarify your intentions.
Entries are deleting by changing the entry status to “2”. The following example deletes two “person” entries from the database.
<?xml version="1.0" encoding="utf-16" ?> <data> <person idperson="1001" status="2"/> <person idperson="2001" status="2"/> </data>
The following xml is returned and contains the transaction id of this operation.
<?xml version="1.0" encoding="UTF-16" ?> <xml transactionid="3CADD418-C410-4E67-85D3-DE2B9ACED4C3"/>
The following message is returned if data contains references to entries that doesn't exist in the database.
lsp_getrecord -> 0 record(s) satisfied the criteria. It should have been 1 record(s) (@@table = [person], @@idrecord = 1001).