Posts in Category: crm 2015

Joining Queries in Dynamics

I recently finished a project that required some pretty complicated querying between entities to get at the data.

What I found is that I was making too many calls to get linked data between EntityReferences in my code to the server.

To improve the performance of these calls I made use of the Addlink functionality on the QueryExpression.

Whereas before I was making two calls to get at my entity data, now I was only going to make one.

My initial query looked like this

QueryExpression query = new QueryExpression(); query.EntityName = "ENTITY"; query.Criteria.AddCondition(new ConditionExpression("ATTR_FILTER1", ConditionOperator.Equal, APPID)); query.Criteria.AddCondition(new ConditionExpression("ATTR_FILTER2", ConditionOperator.Equal, SearchId)); query.ColumnSet = new ColumnSet(new string[] { ENT_LOOKUP_ID, ENT_LOOKUP_ID2 }); 

var plink = query.AddLink("ENTITY2", ENT_LOOKUP_ID2D , ENT_LOOKUP_ID2 , JoinOperator.Inner); plink.EntityAlias = "PH"; plink.Columns.AddColumns("ATTR_FILTER4", "ATTR_FILTER5");

 

When executed as a normal query, this in turn

Read More


Adding Items to a Dynamics Queue

Continuing off my post of adding items to a queue programmatically, I wanted to add items to this queue (why else would I be using a queue?).

The code here is relatively simple and boring as I queried for a contact named Andrew, found him and added a new queueitem to the queue.

QueryExpression queryContact = new QueryExpression();
queryContact.EntityName = "contact";
queryContact.ColumnSet = new ColumnSet(true);
queryContact.Criteria.AddCondition("firstname", ConditionOperator.Equal, "Andrew");

EntityCollection entityContacts = _CrmService.RetrieveMultiple(queryContact);
EntityReference contactRef = new EntityReference("contact", entityContacts[0].Id);

Entity q = new Entity("queueitem");
q["queueid"] = new EntityReference("queue", _QueueId);
q["objectid"] = contactRef;
_CrmService.Create(q);

The results were anything but.

The first time I executed this code it worked fine, created a new queueitem record and associated to my man Andrew.

The second time I executed this code, it exploded with the following message (which seems odd for a queue to do).

Read More


Accessing Dynamics Queues Programmatically

I typically still code in Dynamics using LateBound requests.  There have been a few instances where I have switched to Early Bound but I continue to do this for the following reasons

  1. I don’t like dragging around proxies into my code that can change environment to environment.
  2. When not depending on proxies, I feel have more options to downgrade my code into different versions based on what can be discovered.
  3. I get to learn about all the hidden relationships between entities and attributes that gives me a deeper understanding of what lies beneath.

With that said, this week I needed to access some queues in Dynamics and see what was in them.

To do this, I queried Dynamics for my queue based on the name provided.

QueryExpression query = new QueryExpression();
query.EntityName = "queue";
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition("name",															

Read More


Creating a Custom Interactive button in Dynamics

It’s been awhile since I played with the Ribbon Workbench and I had to re-familiarize myself with it to deploy some custom button functionality to a Dynamics tenant.

If you’re not familiar with the Ribbon Workbench, go download it and bask in it’s glory and time saving capabilities.

Once you install the solution into your Dynamics system, usage is as simple as selecting the solution you want your new button to be deployed to, dragging a button onto the Form toolbar and creating a command object that calls a function in your specified JavaScript file.

Creating the Button

As you can see from the screenshot, my function is called SendMail and called from a library within the provided file.  When I first started coding this button, I added a simple alert() to the

Read More


Improve Query Performance to Oracle

I recently had an issue where we were migrating a large Oracle database into Dynamics which required a significant amount of lookups back to Oracle for synchronization keys between both systems.

When we moved the system between different database environments we started to see the following errors.

“ORA-12801: error signaled in parallel query server P001\nORA-12853: insufficient memory for PX buffers: current 1632K, max needed 80640K\nORA-04031: unable to allocate 65560 bytes of shared memory (\”large pool\”,\”unknown object\”,\”large pool\”,\”PX msg pool\”)”  

As a developer, I get very worried when code changes are required between environments when all other variables stay the same (i.e., database, code, etc).  In this case however, we had been lucky that we had not run into this problem in DEV.

Where I was dynamically constructing the query on the fly, Oracle saw

Read More