Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

New to CRM, using the service methods available

$
0
0

Hi folks,

First, let me tell you that this is the first time I'm using CRM code to access the tables, so please bear with me.

The standard ContactBase table has been altered by the user and has added a few new fields as customization for what the company needs.

I have the seen the quickstart.cs code to create, update, delete and retrieve rows, but they are all focused on GUID that's been created by CRM.

Now, my problem is I need to check one of the new fields added before I use the existing built-in "Insert" crm service method to check for row existence. I have tried to use the RetrieveMultiple method, and ran the SQL profiler to see what it actually does. It accesses the ContactBase table with an alias of "contact0". It returns the id that I want, as seen by the code below, but my problem is how to display several more fields (like select * from [tablename]) and why does it throw an error when I add another column in the columnset, when in fact the column is already in the table?

ConditionExpression condition1 = new ConditionExpression();
                condition1.AttributeName = "new_field1";
                condition1.Operator = ConditionOperator.Equal;
                condition1.Values.Add("123");


                FilterExpression filter1 = new FilterExpression();
                filter1.Conditions.Add(condition1);

                QueryExpression query = new QueryExpression("contact"); ;
                query.ColumnSet.AddColumns("new_field1", "new_employeeID");
                query.Criteria.AddFilter(filter1);

                var x = _orgService.RetrieveMultiple(query);
                foreach (var entity in x.Entities)
                {
                    Entity testAccount = (Entity)entity;
                    MessageBox.Show(testAccount.Attributes["new_field1"].ToString());
                }

This code will throw an exception 

'Contact' entity doesn't contain attribute with Name = 'new_employeeID.'

 but it is there in the table. If I remove this field, everything works out fine.

1. What are the entities in CRM and how do the tables being classified under what entity?

2. How to see the join under the hood when the service methods are called? Can you provide a link to the technical details and usage for coding?

3. I don't now if using RetrieveMultiple is the right way to go to query row per row, because I have almost 1 million rows to check? Any other way to query the ContactBase?

Thanks

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 8223

Trending Articles