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…

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


At times instead of using appSettings section we would like to define our own custom section within configuration file.

 

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

 

<SimplConfigSection id=myID name=myName />

 

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

 

// inherit the class ConfigurationSection

    class SimpleConfigSection : ConfigurationSection

    {

        public SimpleConfigSection()

        {

        }

 

        // using ConfigurationProperty attribute to define the attribute

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

        public String ID

        {

            get

            { return (String)this[“id”]; }

            set

            { this[“id”] = value; }

        }

        // using ConfigurationProperty attribute to define the attribute

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

        public String Name

        {

            get

            { return (String)this[“name”]; }

            set

            { this[“name”] = value; }

        }

    }

 

 

Now to register your custom section do the following

 

<configSections>

<section name=SimplConfigSection            type=Namespace.SimpleConfigSection, Namespace />

</configSections>

 

 

And to use it within the application

 

SimpleConfigSection simpleConfig = (SimpleConfigSection)ConfigurationManager.GetSection(“SimplConfigSection”);

            string id = simpleConfig.ID;

            string name = simpleConfig.Name;

 

 

That’s it …

Logging off from Oracle\Siebel CRM On Demand Web Service within a .NET application


There are two ways of logging off from an active session within CRM On Demand

 

// pass the url in that case no need to set the header

// only set sessionid           

string logoffUrlString = “servername/Services/Integration;jsessionid=” + SessionID + “?command=logoff”;

HttpWebRequest req = HttpWebRequest)WebRequest.Create(logoffUrlString);         

// make the HTTP call

HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); 

 

Or else

 

string logoffUrlString = “servername/Services/Integration?command=logoff”;

HttpWebRequest req = HttpWebRequest)WebRequest.Create(logoffUrlString);         

// set the session id in header

req.Headers[“JSESSIONID”] = SessionID;

// make the HTTP call

HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); 

 

Within Web Services Utilization List of Admin Tab in the CRM On Demand application we can see the login and logout info.

 

That’s it ..