Removing records and relationships thru Web Services

sugarcrmdevelopers —  November 13, 2012 — Leave a comment

Came across this question on Stack Overflow recently…

SugarCRM Web Service API provide only methods for Set and Get entries/relationships.

How can I do delete/remove entries and their relationships with entries in other modules?

Is the Web Service API designed only for Get and Set?

Help please…..

While our documentation doesn’t make it evident, both options are possible via the web services API. Let’s look at how.

For deleting a record, remember under the hood that Sugar “soft deletes” records, meaning that the record is marked with a deleted flag and not just deleted from the database. So to make this change, you can simply issue a set_entry call to set the deleted flag to 1 as shown below…

For removing relationships, there’s actually an extra parameter named ‘delete’ you send to the set_relationship call to indicate that you will be removing the relationship between the two records over the given link instead of adding it. You can then check in the result for the ‘deleted’ counter to make sure the deletion actually occurred. See the below example…

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s