read csv into crm

Hi Guys,


i want to read a csv file into crm (for example account  entity). Before map the csv records in crm i need to test if the records exist or not, if they are identic or if they are not exist then i can respectively update, fill contain in or create new one. How can i proceed i.e zest and map the records in crm?


Thanks


 



AW: read csv into crm

Hi,


what you need to do is using a 3rd Party Tool (for example ImportManager Professional or Scripe) to do so or using SDK to program your own solution for this topic.


Best regards



AW: read csv into crm

Thanks for your answer. The use of third party tool is me too expensive, so the best way stills SDK programming bu my question how i can do it ? i m a beginner in crm, i need the right source code to test the records from datatable with them from crm. Can u help me?


Thanks



AW: read csv into crm

Everything you need is written down with examples in the sdk - take a look. A short tip: You´re a beginner - don´t you think you´ll spend too much time to come to a final release of your solution? Take a look at the price of the 3rd Party Tool and then calculate your investment of time vs. this solution...


Best Regards


 



AW: read csv into crm

I mean i m here in development forum, we talk i think more about code not the algorithm! i ve study software management, i m not a great developer but the SDK didn't contains such code sorry!! i mean here is much c# programming than SDK. To write the records after test them in crm is what i need (code)...


Thanks



AW: read csv into crm

Take a look at the file 'CRMSDK\sdk samples\howto\dynamicentityhowto.cs'


It contains samples of all steps you'll need for your project:


- create contact


- retrieve contact


- update entity


 


Getting the data from your csv source should be the easiest part. Maybe this helps: http://www.codeproject.com/cs/database/CsvReader.asp


Try searching newsgroups, otherwise.


 


"i mean here is much c# programming than SDK"


What do you mean by that?



AW: read csv into crm

Thanks Matzer,


i ve already take a look at SDK sample but don't really see how to retrieve a contact or update an entity. Could you maybe copy the source code from SDK and send me here?


With "i mean here is much c# programming than SDK" i mean the csv file is an externe file which will be mapped in crm after success of some tests (see previous article).Naturely to realize this target we need  a c# code.


Thanks



AW: read csv into crm

See the file attached...


 



AW: read csv into crm

#region Update the DynamicEntity


// This part of the example demonstrates how to update properties of a


// DynamicEntity.


// Set the contact properties dynamically.


// Contact Credit Limit


CrmMoneyProperty money = new CrmMoneyProperty();


// Specify the property name of the DynamicEntity.


money.Name="creditlimit";


money.Value = new CrmMoney();


// Specify a $10000 credit limit.


money.Value.Value=10000M;


// Contact PreferredContactMethodCode property


PicklistProperty picklist = new PicklistProperty();


// Specify the property name of the DynamicEntity.


picklist.Name="preferredcontactmethodcode";


picklist.Value = new Picklist();


// Set the property's picklist index to 1.


picklist.Value.Value = 1;


// Contact ParentCustomerId property.


CustomerProperty parentCustomer = new CustomerProperty();


// Specify the property name of the DynamicEntity.


parentCustomer.Name = "parentcustomerid";


parentCustomer.Value = new Customer();


// Set the customer type to account.


parentCustomer.Value.type = EntityName.account.ToString();


// Specify the GUID of an existing CRM account.


// SDK:parentCustomer.Value.Value = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC");


parentCustomer.Value.Value = accountID;


// Update the DynamicEntities properties collection to add new properties.


// Convert the properties array of DynamicEntity to an ArrayList.


ArrayList arrProps = new ArrayList(entity.Properties);


// Add properties to ArrayList.


arrProps.Add(money);


arrProps.Add(picklist);


arrProps.Add(parentCustomer);


// Update the properties array on the DynamicEntity.


entity.Properties = (Property[])arrProps.ToArray(typeof(Property));


// Create the update target.


TargetUpdateDynamic updateDynamic = new TargetUpdateDynamic();


 


// Set the properties of the target.


updateDynamic.Entity = entity;


// Create the update request object.


UpdateRequest update = new UpdateRequest();


// Set request properties.


update.Target = updateDynamic;


// Execute the request.


UpdateResponse updated = (UpdateResponse)service.Execute(update);


#endregion


---------------------------------------------------------------------------------------------


This is nice but my problem stills!!


1) the previous code is an update for money and not for account which is quiet different.


2) imagine i have read my data from csv file in a datatable and i ve fill them in crm by create function. At this step i ve create in crm a new account.


Admitted i ve my datatable and want to map it in crm, but this firma already exists and hat in some records old contain which will be updated, and some are empty, will be filled in and finally some are not exists will be new created.


Question: How i proceed? how can the code look like, i mean test the 3 possiblities(data old, empty or not exist) and for every one write the solution. In another hand how can i in c# compare the records from crm with them of my datatable and vis versa? Do you ve maybe a similar code?


Regards



AW: read csv into crm

@1) actually the code does update an account.... it's updating the credit limit, an attribute of type 'money'.


Just take the samples as a basis. Of course you have to modify it, fitting your requirements. 


Use the "retrieve"-Code to fetch data from CRM system... if nothing is returned -> go create the account. If something is returned: check if data is old, then update the crm record with the data from csv file (see update-example), and so on. Look in MSDN what other types of attributes are there besides 'money'. Searching for 'CrmMoneyProperty' will point to the msdn postings you are looking for.


I can't provide you the full code to solve your problem...



Re: AW: read csv into crm

Hi matzer,


could you please try again to attach a file? I modified the appropriate security settings for registerd users.


Best regards,



AW: read csv into crm

Thanks,


i try it right now.


Regards



AW: read csv into crm

so can look the small modification in your code like:


#region Retrieve Contact Dynamically


// Create the retrieve target.


TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();


// Set the properties of the target.


targetRetrieve.EntityName = EntityName.account.ToString();


targetRetrieve.EntityId = created.id;


// Create the request object.


RetrieveRequest retrieve = new RetrieveRequest();


// Set the properties of the request object.


retrieve.Target = targetRetrieve;


retrieve.ColumnSet = new AllColumns();


// Indicate that the BusinessEntity should be retrieved as a DynamicEntity.


retrieve.ReturnDynamicEntities = true;


// Execute the request.


RetrieveResponse retrieved = (RetrieveResponse) service.Execute(retrieve);


// Extract the DynamicEntity from the request.


DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity;


// Extract the fullname from the dynamic entity


string fullname;


string city;


string country


string address1_telephone1


string address1_line1



 


for (int i = 0; i < entity.Properties.Length; i++)


{


if (entity.Properties[i].Name.ToLower() == "fullname")


{


StringProperty property = (StringProperty) entity.Properties[i];


fullname = property.Value;


break;


}


if (entity.Properties[i]. address1_city.ToLower() == "fullname")


{


StringProperty property = (StringProperty) entity.Properties[i];


city = property.Value;


break;


}


if (entity.Properties[i]. address1_country.ToLower() == "fullname")


{


StringProperty property = (StringProperty) entity.Properties[i];


country = property.Value;


break;


}


if (entity.Properties[i]. address1_telephone1.ToLower() == "fullname")


{


StringProperty property = (StringProperty) entity.Properties[i];


telephone1 = property.Value;


break;


}


if (entity.Properties[i]. address1_line1.ToLower() == "fullname")


{


StringProperty property = (StringProperty) entity.Properties[i];


line1 = property.Value;


break;


}


}


#endregion


----------------------------------------------------------------------------------------------


Is that right? Could you write me the code of this sentence: "Use the "retrieve"-Code to fetch data from CRM system... if nothing is returned -> go create the account. If something is returned: check if data is old, then update the crm record with the data from csv file (see update-example), and so on"


The string use in datatable is declared as previous. The need entities is from type account.


 


Thanks



AW: read csv into crm

i ve study the code you hat send me, but it wasn't match with my wish! sorry i see there a big confusion between entity and attribute on your side. This code cannot be recommended! Definety the need code will come from pur c# programming.


Thanks


 


 



AW: read csv into crm

sorry i see there a big confusion between entity and attribute on your side


1. ha


This code cannot be recommended


2. ha


Definety the need code will come from pur c# programming.


3. ha


 


Conclusion: hahaha.


You were advised not to solve your problem by programming something on your own, since you are a beginner, as you said. You got all pieces needed for your solution and now blame others, who tried to help, because you cannot put the pieces together...what we already assumed in the beginning, therefore the hint to use a 3rd party tool.


Studying 'software management' isn't everything...


Bye.