Generic SQL Error – RetriveMultiple with ConditionOperator.Contains in CRM

Today someone “me” wanted to change the requirements of the wrap I have over the CRM web services so I could reuse the method more often, but to do so I need to transform the method more standard. So I changed the ConditionOperator.Equal to ConditionOperator.Contains. But was giving me an error “Generic SQL Error” while using in the ConditionExpression. The requirement was to get all the records from an entity that contains a specific field with a certain attribute value.

Before, using Equal:

Microsoft.Xrm.Sdk.Query.ConditionExpression condition = new Microsoft.Xrm.Sdk.Query.ConditionExpression(FieldName), Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, AttributeValue);

After, using Contains: You need to add % to the attributevalue but don’t work if the table or indexed view is not full-text indexed, therefore you need to use Like.

Microsoft.Xrm.Sdk.Query.ConditionExpression condition = new Microsoft.Xrm.Sdk.Query.ConditionExpression(FieldName), Microsoft.Xrm.Sdk.Query.ConditionOperator.Contains, “%”+AttributeValue+“%”);

After, using Like: You need to add % to the attributevalue

Microsoft.Xrm.Sdk.Query.ConditionExpression condition = new Microsoft.Xrm.Sdk.Query.ConditionExpression(FieldName), 
Microsoft.Xrm.Sdk.Query.ConditionOperator.Like, “%”+AttributeValue+“%”);

Annunci

MSCRM365 Hide Warning notification in the Email.

Before to start with this post I have to say that this is AN UNSUPPORTED solution! Think about that before to use.

Now I can start to explain: I created an email template with style and script tags inside. In MSDCRM365 emails that are seen as an unsecure email and we have a yellow message notification in the body.

That is not a problem because the mail is sent but there is a “bad yellow” notification on the body:

The way to do that is to comment the Javascript code inside the formcontrols.js file in the Microsoft Dynamics CRM codes:

$get(‘WarningWithOpen’, this.$v_2).style.display = ‘block’;

$get(‘WarningWithOpen’, this.$v_2).style.display = ‘none’;//robm 12-08-2016 ‘block’;

(change all the occurences)

And add the following row in the AcrivitiesWallContent.css.aspx file:

.emailnotification {display: none;}

 

AS I SAID THAT IS UNSUPPORTED SOLUTION, AND YOU MUST THINK 100 TIME BEFORE TO USE!

 

MSCRM – Default entities and status code

Today I want talk about Status and Status Reason. Status and Status reason are both optionsets. Option set have an int value and a text value. The text value is meta data and the int value is held in the database on the database field.

Default entities have two status values

State
• Active = 0
• Inactive = 1

Status reason have different default values:

Status Reason
• Active = 1
• Inactive = 2

 

Microsoft MVP 2016 – Business Solutions – Dynamics CRM

indexI am proud to announce that I just received my 1st Microsoft MVP Award for my focus in Business Solutions – Dynamics CRM.

Congratulations! We are pleased to present you with the 2016 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Business Solutions technical communities during the past year.

Also in this email:

About your MVP Award Gift
How to claim your award benefits
Your MVP Identification Number
MVP Award Program Code of Conduct

The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say “Thank you for your technical leadership.”

Patrick Malone
Director
Community & Advocacy Programs
Microsoft

The Microsoft MVP award and the included opportunities add a huge benefit like the Microsoft MVP summit where you have the chance to talk to the Microsoft Product Groups, learn and place feedback. But of course the Microsoft MVP award also adds some other great advantages.

Of course there are a lot of people I have to thank, but I want to keep the list as short as possible. I would like to thank my employer which is supporting me in the best possible way year over year, my current and former colleagues, the Microsoft MVP community and of course Microsoft employees in Redmond and all over the world.

CRM2011/2016 – Timeout problem when open Sharepoint documents from CRM

Today I had a big problem with our new customer: When they tried to open a document from CRM, they had an error:

a

After check a little bit, I found a timeout error on sharepoint.  The problem was the Cookie life time configuration:

[..]When using FBA or a trusted provider, SharePoint will set a cookie on the client called FedAuth. I’ll not go into the details of what’s inside the FedAuth cookie. Of course, the FedAuth cookie will have by default a certain lifetime. Session cookies can be configured too making the cookie invalid after the closing the browser and then bypassing the value in this settings.

The default value is 5 days.[..] (Microsoft text)

cp1

To resolve the problem I found this script:

$sts = Get-SPSecurityTokenServiceConfig
$sts.CookieLifetime = New-TimeSpan -Hours 7
$sts.Update()

At the end I restart IIS and all is run in right way.

#CRM2016 – Get all teams by user in C#

public Microsoft.Xrm.Sdk.EntityCollection UserTeams(Guid UserID)
{

    QueryExpression query = new QueryExpression("team");
    query.ColumnSet = new ColumnSet(true);
    LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");
    link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, UserID));

    try
    {
      return service.RetrieveMultiple(query);
    }
    catch (Exception ex)
    {
       // Do your Error Handling here
       throw ex;
    }
}