The ConditonOperator.Equal requires 1 value, not 0.


This error is recieved when for ConditionExpression, we would have set

AttributeName, Operator properties but haven’t set Values property.

The below code would result in the ConditonOperator.Equal requires 1 value, not 0 error.

ConditionExpression myCon = new ConditionExpression();
myCon.AttributeName = “createdbyname”;
myCon.Operator = ConditionOperator.Equal;
//line commented for reproducing error
//myCon.Values = new object[] { “username” };

Bye..

Understanding LookUp In CRM


Hi find out this nice post about LookUp by JimWang.

http://jianwang.blogspot.com/2008/05/mysterious-crm-lookup-i.html

Do Check it ..

Bye..

Error 0x80041110 QueryByAttribute must specify a non-empty attribute array in CRM


This error occurs when using the QueryByAttribute class we are not setting the Attributes and Values Property.

 

Just like the below code

 

Say we want to have the names of all the accounts,

 

ColumnSet myCols=new ColumnSet();

            myCols.Attributes=new string[] {“name”};

   QueryByAttribute myQA = new QueryByAttribute();

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

            myQA.ColumnSet = myCols ;           

            BusinessEntityCollection myBCColl2= myService.RetrieveMultiple(myQA);

 

However we will get error in this case because we haven’t specified Attributes and Values property. So we need to specify those properties.

 

            myQA.Attributes = new String[] { “statuscode” };

            myQA.Values=new object[] {“1”};

 

Otherwise we could use QueryByExpression class for that

 

            ColumnSet myCols=new ColumnSet();

            myCols.Attributes=new string[] {“name”};

 

            QueryExpression myQE = new QueryExpression();

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

            myQE.ColumnSet = myCols;

 

            BusinessEntityCollection myBCColl1 = myService.RetrieveMultiple(myQE);

 

 

Bye ..

SharePoint Mobile View


To access the mobile view of our SharePoint sites, we just need to do the following,

just append to the url _layouts/mobile

from

http://servername:port

to

http://servername:port/_layouts/mobile

That’s it..

Using Hyperlink in WPF application


To user hyperlink in WPF application we could do something like this

 

<TextBlock>

<Hyperlink NavigateUri=”http://www.google.co.in”&gt;

            Click here

</Hyperlink>

</TextBlock>

 

However the NavigateUri works only if we are placing the hyperlink within a page. To use it within a windows-based application we need to hanlde the RequestNavigate event and write the code ourselves.

 

Something like this

 

<TextBlock>           

<Hyperlink NavigateUri=”http://www.google.co.in&#8221; RequestNavigate=”Hyperlink_RequestNavigate”>

 Click here

</Hyperlink>            

</TextBlock>

 

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)

  {

            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));

            e.Handled = true;

  }

 

While using hyperlink we could also provide handler for Application.NavigationFailed event in case if navigation fails.

 

That’s it ….

 

Using Custom Configuration Section and Configuration Manager class in .NET – 2


Suppose we  want to create a custom config section in this following manner

 

<queryTypes>

    <queryType name=qt1 value=qt1 value></queryType>

    <queryType name=qt2 value=qt2 value></queryType>

</queryTypes>

 

For implementing the above custom section we need to first define a class inheriting from ConfigurationSection class

 

Add reference to System.Configuration dll.

 

Create a new config section class in the following manner

 

    // implement ConfiguraionSection class

    class QueryTypesSection : ConfigurationSection

    {

        public QueryTypesSection()

        {

        }

        [ConfigurationProperty(“”, IsDefaultCollection = true)]

        public QueryTypesCollection QueryTypes

        {

            get

            {

                return (QueryTypesCollection)base[“”];

            }

 

        }

 

    }

    // Represents a configuration element containing a collection of child elements   

    public sealed class QueryTypesCollection : ConfigurationElementCollection

    {

        protected override ConfigurationElement CreateNewElement()

        {

            return new QueryTypeElement();

        }

        protected override object GetElementKey(ConfigurationElement element)

       

        {

           

            return ((QueryTypeElement)element).Name;

        }

        public override ConfigurationElementCollectionType CollectionType

        {

            get

            {

                return ConfigurationElementCollectionType.BasicMap;

            }

        }

        protected override string ElementName

        {

            get

            {

                return “queryType”;

            }

        }

    }

    // Defining QueryTypeElement with name and value attribute

    public sealed class QueryTypeElement : ConfigurationElement

    {

        // defining name attribute

        [ConfigurationProperty(“name”, IsRequired = true)]

        public string Name

        {

            get

            {

                return (string)this [“name”];

            }

            set

            {

                this[“name”] = value;

            }

        }

 

        // defining value attribute

        [ConfigurationProperty(“value”, IsRequired = true)]

        public string Value

        {

            get

            {

                return (string)this[“value”];

            }

            set

            {

                this[“value”] = value;

            }

        }

 

    }

 

 

Now to register your custom section do the following

 

<configSections>

<section name=queryTypes type=namespace.QueryTypesSection, namespace />

</configSections>

 

 

And to use it within the application

 

 

  QueryTypesSection queryTypeSection = (QueryTypesSection)ConfigurationManager.GetSection(“queryTypes”);

            QueryTypesCollection  queryTypeCollection = queryTypeSection.QueryTypes;

            foreach (QueryTypeElement se in queryTypeCollection)

            {

                string name=se.Name;

                string value = se.Value;

            }

 

 

That’s it…

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓