Retrieving a single Guid in CRM 4.0

Posted by user1746560 on Stack Overflow See other posts from Stack Overflow or by user1746560
Published on 2012-10-18T10:48:33Z Indexed on 2012/10/18 11:00 UTC
Read the original article Hit count: 137

Filed under:
|
|
|

I'm new to CRM (version 4.0) and i'm trying to return a 'yearid' guide based on a given year (which is also stored in the entity).So far i've got:

    public static Guid GetYearID(string yearName)
    {

        ICrmService service = CrmServiceFactory.GetCrmService();

        // Create the query object.
        QueryExpression query = new QueryExpression("year");
        ColumnSet columns = new ColumnSet();
        columns.AddColumn("yearid");
        query.ColumnSet = columns;       

        FilterExpression filter = new FilterExpression();

        filter.FilterOperator = LogicalOperator.And;
        filter.AddCondition(new ConditionExpression
        {
            AttributeName = "yearName",
            Operator = ConditionOperator.Equal,
            Values = new object[] { yearName}
        });

        query.Criteria = filter;

    } 

But my questions are:


A) What code do in addition to this to actually store the Guid?
B) Is using a QueryExpression the most efficient way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about dynamics-crm