Hello all,
Iām brand new to SuiteCRM. Indeed, Iām new to CRMs in general. I have it running on a Debian server, using MySQL and Nginx in case that matters. Iām on version 7.9.6.
Right now, Iām getting used to things as I work with my boss to evaluate SuiteCRM and see if itās a good fit for the company. The task Iāve just been given is to take records from our AS400 and import them, then merge them daily, into SuiteCRM. I have a long list of customer accounts which I have to turn into accounts with one or more contacts per account, a list of sales reps I have to turn into users, and relationships between them I have to automatically create. Iāve so far come up with the following questions:
How can I create links between records, existing or imported? Assigning users to own accounts or contacts, making a contact be contained in an account, that kind of thing?
Once I know what Iām doing, will I be able to automate this whole process? Iād like to query the 400, generate a file or pass some JSON into a program, and update everything once a day or so.
I know more questions will come up, but thatās it for now. The manual explains things pretty well, but it doesnāt mention automation or connecting records to those in other modules. Thanks for any help.
For learning how to automate, check out Jim Mackinās eBook āSuiteCRM for Developersā.
There are a few different approaches, using PHP and ābeansā to import intelligently, or directly writing into the database with SQL, or preparing things in Excel/Calc and then importing through the UI.
Iām a programmer, more or less, so SQL is fine with me. I just donāt know the table structure enough to make sure I get things right. A single table is easy, since I can just look at the columns, but itās the relationships I worry about. Is there anywhere that lays out how to tie members of modules together, setting up parents and the like? PHP would be fine, too, if that would be easier than SQL queries.
Speaking of parents, is there any way to define that right in my CSV file for basic or automated importing? Thanks again!
If you can do PHP youāre better off than directly with SQL, because the SuiteCRM ābeansā classes will take care of building those relationships for you. Thatās all in the eBook.
SQL: if you examine the database with phpmyadmin you can get a sense of how the tables connect. Each record has an id (like 72c555b3-0ead-d66c-4c2a-57549a2e130b), but you can create your own as long as itās a unique identifier. Look for tables called like accounts_contacts where the relationships are created (linking and id from contacts to an id from accounts).
CSV imports can do some very basic relationships, I think - like if you import a Contact with a field called Account that matches an existing Account in the database, I think SuiteCRM will link it up as a relationship. But I never really tried it.
PHP, specifically using beans, does indeed seem to be my best bet. One thing I canāt quite work out, even after reading the chapters of the book, is what to include to get my PHP to recognize all the SC classes Iāll need to work with beans. Iām looking through the modules included in 7.9.6, but Iām not finding much to get me started.
Say I have a contact. Iāve manually set up a user with the username of ahall. I want to add a contact to ahall, and to a company called Alexās Company. My contact should be part of that account as well as the ahall user. Hereās my guess, written mostly in pseudocode:
//include the necessary files
require(??);
//get the userās account
$userBeanID = 0;
$userBean = BeanFactor::newBean(āUsersā, $userBeanID)
$userBean->get_list(āahallā)[0]; //assuming 1 result
if($userBeanID === null) { //this is a new record, so our user must not exist
echo āUser does not exist.ā;
exit;
}
//add the contact bean?
$contactBean = BeanFactory::newBean(āContactsā, $contactBeanID);
//$contactBean is a new bean, hopefully; weād run the ID check here, making sure it IS null this time
$contactBean->firstName = āJohnā;
//and so on
$contactBean->save();
//we now need to relate the two beans, somehow
$userBean->contacts->//not sure here
Hopefully you can see what Iām going for, and where Iām unsure. Eventually, Iāll be automating this, likely by having a PHP file read a text file created by a query run against our AS400. For now, though, I just want to work out the process for making new beans, modifying the correct existing ones, and establishing relationships between beans. Thanks.
Thanks! I have a PHP file that displays the number of users, but that simple thing means all the behind-the-scenes stuff is working as expected.
One question though. Is there a faster way to test changes? Right now, I :qw in VIM, run a quick repair, and have to go from there back to the test page. Can I make it so I need only refresh the test page? Development Mode is probably good for that, but will that have any consequences I should consider before enabling it?
Why do you run a Quick Repair? I donāt think itās needed.
Depends on what youāre changing, of course, but for this kind access-the-beans stuff no repair is needed. Only when you change files that SuiteCRM needs to āpre-processā in order to generate other files.
So I think you only need to refresh the test page.
Refreshing doesnāt load any changes. Iāve found that, even with developer mode enabled, my changes to testEntryPoint.php arenāt shown until I do a repair. Did I put the file in the wrong place? I followed the bookās instruction and put it in suiteCRM_dir/custom/extension/application/Ext/EntryPointRegistry. It works, and I even see incorrect queries appearing as fatal errors in suitecrm_dir/suitecrm.log as I hoped. But my PHP wonāt do anything I tell it to until I run a quick repair, for some reason.
No, really, you should not need a QRR. There must be some cache betraying you in-between.
What is the URL youāre using to access your file?
Have you tried a CTRL-F5 refresh, instead of a simple F5?
Also, try changing the file, and then accessing it from another browser youāve never used for this. That way you can tell whether itās alocal cache problem, or a server-side cache problem.
Good ideas. Ctrl-f5 didnāt help. Neither did switching browsers. I modified my php file, and tried your suggestions as well as restarting Nginx and PHP5-FPM. In all cases, I saw the old PHP file. I even tried turning the āsendfileā command off in nginx.conf, but that didnāt seem to make a difference, so I turned it back on. Only a quick repair and rebuild seems to force SC to pick up my modifications, for some reason.
Unrelated to updating files, Iām trying to get related beans to work. Iām just added a user with a bean, which is great. Now I want to do two things: add an email address for that user, and make an account owned by the user. The account should actually be easier, as I canāt figure out which module to use to give users email addresses.
I suppose I have two questions. How do I assign an email address to a user, and how do I make a user own an account? Iām reading the part of the book on relationships, but Iām not quite getting it. How are relationships tied to beans? How do I specify ownership once I have beans for, say, a user and an account loaded? I can obtain/create beans, but I donāt understand how to tie them together. Thanks.
If $person is a Contact Bean, you can simply assign
$person->email1 = "me@there.com"
And then, what do you mean to āownā the Account?
if you mean have the account assigned to someone, then that is a field you set in the bean:
global $current_user;
$cuser = $current_user->id;
$bean->assigned_user_id = $cuser;
If you mean make the Account be part of a security group, then something like this:
if (is_null($account)) {
$account = BeanFactory::newBean("Accounts");
$account->parent_id = $parent_account_id; // for nested accounts
$account->name = $newname;
$account->save();
$securityTeam = new SecurityGroup();
$securityTeam->retrieve_by_string_fields(array('name' => $secgroupname ));
$account->load_relationship('SecurityGroups');
$account->SecurityGroups->add($securityTeam->id);
}
Youāll have to adapt that code. With this bit I think you can learn how to use relationships, since setting the Security Group is setting a relationship. You can do a similar thing to make a Contact belong to an Account. There are many examples online (once you know what to search for). Good luck.
Thanks for the in-depth answer! Iām surprised that email1 will work, since I didnāt see it in the list of fields for users when I was looking around the studio. But Iām glad itās that easy!
Yes, I meant your first example, where an account is bound to a user. That way, each salesperson can have their own accounts, with contacts in each account, and not worry about other accounts. Iāll use groups, but I think for contacts, accounts, meetings, notes, and most other things, Iāll just be assigning directly to users if I have to automate entry of any of them.
I also realized I didnāt answer your question about my URL for the non-refreshing PHP file. I go to:
where testEntryPoint is the name I define in my PHP file. It loads that way, so I know it works, but nothing I do will get updates to the PHP to show on the site except a QRR.