Search form

You are here

In one of our recent project I have used CiViCRM with Drupal. I have to build a CRM profile edit page inside Drupal. In past we had created similar functionality in one another project but that was implemented by direct CiViCRM database read/write operation. But in this project I've implement this using the CiViCRM API. I faced some problem and it was taking much time to figure out the right way to do this in some case. So I'm sharing this experience with all hoping that it may save some time if in case you need the same functionality.

How you will read the CRM profile data?

You need to initialize the API first.

<?php if (!civicrm_initialize()) { return; }?>

If you don't know the CRM contact ID then you have to get it by the Drupal user ID.

But updating multi select dropdown values or other type of fields are not so simple. So it was time consuming for me to figure it out. We have a multi select list for 'Area of Interest' field. So we have updated this as follows.

Now the file Entity has been created. So you have to update the custom field value by the newly created file ID. I couldn't do this using the API so lastly for saving time I did this by direct database query. I will figure out the this when I will get time for this :).