Where we can find insert query for each module while create new entry in suiteCRM

Hi ,
Just I want to know where we can find the insert query for each module like If I take contact module I want to see the insert query when I click on save button (where I can find that code ).

The table name is contact and I need to know where is this insert query in suiteCRM.

Please help on it please

Hi,
I’m not on my notebook with my IDE, but I think its this one:

look for public function save($check_notify = false). But before you start modifying this file: what is your intention? I’m convinced your usecase can be covered with other means.

Hi @crmspace ,

Thanks for you valuable response , I went through your answer and I found data/SugarBean.php

Before I want insert the contact data I need to check duplicate entry with some of the custom phone number fields and if number existing need to avoid that entry and need to give notification.
Note: I knew like this we can do by using studio/module/fields/enable duplicate but In that case still possible to add the records but I won’t that please give me some suggestion .

What I am trying : I need to avoid duplicate values from some of the phone number fields which I created (custom).

Thanks
Sandeep

Hi,
then I would not alter this method. It’s a core method and there are upgrade-safe ways of accomplishing this validation.

If you would like to have a direct response (while the user is filling in the form), you could:

  • embed a javascript listener in the EditForm that calls an entrypoint with the current phone number (you have to create this entrypoint first). Within the entrypoint, you validate if the phone number is already in use, and if so, you can create an alert or any other notification you would like to see (you can also create error messages that look like the suite ones)

A “backend” approach instead (works therefore also when creating contacts via API):

  • an easier approach: you create a before-save-hook. Every method defined as before-save-hook will be triggered whenever a user is trying to create a record of that module. From there, you can do the same validations and also interrupt the save-process.

Both approaches require some suite-knowledge, hopefully these articles help you get going:

E: within the entrypoint or within a logichook, you should not use direct db queries. Instead, use the bean framework:

1 Like