Skip to content

Commit

Permalink
Start documenting mark_deleted
Browse files Browse the repository at this point in the history
This is better than nothing :-)
  • Loading branch information
pgorod committed Jan 7, 2020
1 parent 116a0d6 commit 6e56367
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions content/developer/Working with Beans.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ weight: 3
title: "Working with Beans"
---

:toc:

= 3. Working with Beans

Beans are the Model in SuiteCRM’s MVC (Model View Controller)
Expand Down Expand Up @@ -341,6 +343,21 @@ record is new (perhaps in a custom import script) then you can set
is new.
{{% /notice %}}

== Marking a Bean as deleted

Use the `mark_deleted` method for this. It will set the `deleted` field to `1`, also mark any relationships of that Bean
as deleted, and remove the reference to that item from the **Recently viewed** lists.

[source,php]
----
$bean->mark_deleted($id);
// Saving is required afterwards
$bean->save();
----

This method will also call the appropriate `before_delete` and `after_delete` logic hooks.

== Related beans

We have seen how to save single records but, in a CRM system,
Expand Down Expand Up @@ -493,7 +510,6 @@ $accountBean->contacts->delete($accountBean->id, $contactBean);


{{% notice warning %}}
Be careful with the
delete method. Omitting the second argument will cause all relationships
for this link to be removed. link:../working-with-beans[↩]
Be careful with the delete method. Omitting the second argument will cause all relationships
for this bean to be removed.
{{% /notice %}}

0 comments on commit 6e56367

Please sign in to comment.