Closed (outdated)
Project:
CRM Core
Version:
7.x-0.961
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Oct 2013 at 19:44 UTC
Updated:
18 May 2019 at 10:41 UTC
Jump to comment: Most recent
Comments
Comment #1
Anonymous (not verified) commented@Ravenight - thanks for using CRM Core! Happy to help with this.
I agree with your point about migration needing to be easy and can add some documentation. Help me out here, what kinds of documentation would be most useful to you?
When I import contacts, entities and relationships, I typically do a lot of data massaging to get information into a form where it can be easily worked with (like a CSV, or a series of CSV files). I use the feeds module and a custom parser to handle the import process, and make good use of entity_metadata_wrapper within the parser to make things a little more sensible.
I could certainly write up some code examples that make this a little easier to understand, but I wonder if that's right for everyone. Is that something you would like to see?
Comment #2
Ravenight commented@techsoldaten - thanks for such a cool module!
I agree about the data massaging and do something similar to get a CSV file. What I would love to see is the custom parser and if it would be possible to turn it into an additional module connected to the feeds import modules. Perhaps similar to how commerce_feeds was done.
More specifically, I am looking for how you import the relationships. For example I have a CSV of Individuals and another one for Companies. In the "individual" csv there is a reference to which company they work for. This would be the "employee of" relationship. How would I import this? And as a followup, would other relationships follow a similar import process - even if they are built using the Relation module instead of within CRM core yet use CRM core data?
Thanks again for the help.
Comment #3
Ravenight commentedI have begun this process and wanted to document a few things for anyone else struggling with this. This is designed for a clean import of new data. I have not tired this out in a working environment with lots of data yet - but I will soon.
Importing New CRM Contacts -> Create User Accounts (Creates the crm_core_user_sync relation when you add a new CRM Contact)
Uses Feeds, Rules
Basic Setup
If you don't do this, you will end up with lots of duplicate contacts.
Feeds Setup
Rules Setup:
First watch this: View a screencast about creating relations with Rules
Conditions: [I cannot figure out how to load a screenshot here, so here is a link to it]
Conditions
Actions:
Actions
This will upon saving a new CRM contact, check to make sure it is an individual, ensure there is an email (I am not validating the email here), creating a new User Account and then linking the two together with a new relation.
The trick was to make sure the new user was saved and loaded BEFORE the Contact in the variable list. That is all there is to it.
If you then want to email a notice to the new user, you can do that too but I am going to do that manually for now via VBO from the People page.
Comment #4
schismfish commentedFirst off I would like to thank you for the fantastic module! I am experienced in using feeds, views and drupal altogether so this was just perfect. :)
I have been developing a CRM-Core Drupal website to replace an older external CRM for a client/company. I've got charting and reports working from test data - imported list/boolean data as machine key so editing works - the system has been great so far!
I have successfully imported thousands of contacts and am ready to import company data - I have also been wondering about how to import or automate the relationship links between contacts(individuals) and companies. In the feeds section I have the option for contacts/activities (and to create more contact/activity feeds) but not for relationships.
I haven't yet attempted activities import (I assume you tie activities with the id set by crm-core/drupal for contacts? Yet to look).
While i'm pretty well versed in using CSV's, Excel and deduplication - around late November I will need to export the data from the old system and re-import fresh as to have everything up-to-date. I don't want to have to set all the relationships/activities manually so close to the user deadline.
Thanks again any advice or documentation you provide will be appreciated. :)
- Tyler
Comment #5
Ravenight commented@ schismfish
The key to the relationship creation is Rules. I found the easiest way to ensure I got what I wanted was to create a dummy or TEMP content type with the fields I needed. It sounds crazy to do this, but hear me out.
Using feeds importer is great unless you have to cross reference two types of data - one CSV with an ID from the old system and another with email from MailChimp for example. The one with ID doesn't guarantee an email address and the other doesn't have an ID. If you use two Import feeds you end up with duplicates since the GUID is different in each feed.
So, I dumped everything into a temporary spot, then ran a rule component with Views Loop to find the data I needed. You can "Fetch an entity by ID or Property" and with this you can check to see if the relationship already exists or not. Then using another component or Rules Conditional, you can either insert a new one after creating a variable of "List of any entity type" and assigning it the endpoints or not.
Turns out it is not too hard to get all this going and my 6k+ rows with 10k+ relationships was not that hard to get going once I figured out how to use Rules to create the entities.
Comment #6
schismfish commentedThanks for your reply Ravenight I have been looking into Rules and am still getting to grips with it.
My data is already in the system - did you trigger the rule when a new contact is made? What could I use as a trigger for updating existing data or would it be best to create this rule and have a fresh import of contacts?
The easiest way for me to possibly relate them is that on my 'contact' type each contains a company name text field which matches exactly the 'household name'/name of the 'organisation' type. if contact > 'company name' is equal to organization > 'name' then relate.
In rules I have seen the data comparison condition - can I specify the crm contact field types there?
Been mega busy last month or so - this could be really simple but my brain is on overload at the minute. Any help would be appreciated. :)
Comment #7
Ravenight commentedI made a Rule component that used the Views Rules module to pull the data through the rule one item at a time. Once you have the node entity you can do whatever you need to with the data.
Comment #8
Anonymous (not verified) commented@Ravenight - I am about to start work on a general relationship importer and would love to see your rule.
Comment #9
jmanny commented@Ravenight
Not sure how to follow up with views rule module, i get lost on what kind of event, condition and how to check if the relationship already exits. is there any way you can explain your method step by step?
Comment #10
mouthofthesea commented@Ravenight @All
comments #3
With your rules settings a found a easiest way to import a contact and create a new account with a relation, Thanks for that.
I only add another Action at the end to unblock the User after the creation.
Unblock a user
Parameter: User: [new-user]
Now I try to figure out another problem, I have two type of crm contacts: Individual and Organization.
This is the content types structure:
Field of Individual
Indi.Contact name, Indi.code, Indi.email
Field of Organization
Org.Contact name, Org.code, Org.Address
My aim is create a rules that link(with a relation) a single Individual and Organization after saving a new crm core contact (Event).
Relation only when Indi.code = Org.code
Pre condition: import all contacts of Organization type
Conditions:
load data with all the fields needed (Indi.code)
(I load this fields via feeds processor with a .csv)
load Indi.code
load all the Org.code in a list
compare data Indi.code = Org.code
If so, create a relation(called Employee of) where Indi.code = Org.code
Any suggestions?
Thanks in advance,
kind regards.
Comment #11
grahlClosing outdated issue, please reopen if still relevant.