Using ALLColumns() in Dynamics CRM

Hi,

To retireve the values for all the attributes of an entity we can make use of ALLColumns ,

CrmService service=new CrmService();

service.Credentials = System.Net.CredentialCache.DefaultCredentials;

QueryExpression query = new QueryExpression();

query.EntityName = EntityName.new_entityname.ToString();

query.ColumnSet=new AllColumns();

BusinessEntityCollection entities= service.RetrieveMultiple(query);

for(int i=0;i<entities.BusinessEntities.Length;i++)

{

new_entityname nEntity=(new_entityname) entities.BusinessEntities[i];

Response.Write(“<b>”+nEntity.new_id+” -></b>”);

Response.Write(“<i>” + nEntity.createdby.name + ” –></i>”);

}

}

Or by using QueryByAttribute  

It can be used when our query is very simple i.e. multiple equals conditions that are combined using AND.

But remember it doesn’t support OR
QueryByAttribute myQuery=new QueryByAttribute();
myQuery.ColumnSet=new AllColumns();
myQuery.EntityName=EntityName.opportunity.ToString();

    // Find all the opportunities with topic name test1 and city as Redmond
myQuery.Attributes=new string[]{“name”,”address1_city”};
myQuery.Values=new string[]{“Test1″,”Redmond”};
BusinessEntityCollection retrieved=service.RetrieveMultiple(myQuery);

Bye

Query for finding Team and it’s member in MS DYNAMICS CRM

Hi,

We can use this query to retrieve different teams and the users belonging to that team within Microsoft Dyanmics CRM

Select FT.name TeamName,FSU.Fullname UserName, FSU.Systemuserid from
dbo.FilteredSystemUser FSU
inner Join
dbo.FilteredTeamMembership FTM  
on FSU.Systemuserid = FTM.Systemuserid
Inner join  dbo.FilteredTeam FT
on FT.TeamID = FTM.TeamID
ORDER BY FT.NAME

Bye

Configuring ASP.NET Web Service

Hi,

Well today i created a webservice which would fetch me some data from oracle database. The method signature was something like this

public DataSet getEmpInfo

{,,,,,,,,,,,,,}

I was calling this webservice within form’s onLoad inside the a custom entity of Microsoft Dyanmics CRM3,0. 

I deployed it in my machine and when i was opening the my custom entity form inside CRM in my machine, i was able to see the values fetched using ajax calls to webservice.

But for other machines i was getting an internal server error for my ajax call.

Finally the error got resolved when i included this inside the web.config for my webservice

<webServices>
    <protocols>     
        <add name=”HttpPost”/> 
        <add name=”HttpGet”/>  

 </protocols>
</webServices>

By the way, I was using POST in my xmlHttpRequest object Open method.

Plzz check out these links to better understand web services.

Configuration Options for XML Web Services Created Using ASP.NET 

http://msdn2.microsoft.com/en-us/library/b2c0ew36(vs.80).aspx

How to: Disable Protocol Support for Web Services 

http://msdn2.microsoft.com/en-us/library/9hdd3w8c(VS.80).aspx

Top Five ASP.NET Web Services Tips

http://www.ondotnet.com/pub/a/dotnet/2002/10/07/webservices.html

Bye

Hiding or disabling elements in Microsoft Dynamics CRM 3.0

Aim : To disable the close opportunity menu item from the Actions Menu for Opportunity form.

Put the following code in the Form_Load script of the Opportunity form

document.getElementById(‘_MIcomplete’).Style=”display:none” ;


Put the id of the menu item there
To get the id name for any particular menu item

  • step 1- open the opportunity form in crm.

  • step 2- press ctrl+N to open the same form in a new window.

  • step 3- right click go to view source and find the id of the required element.

Same thing we can do for buttons added through isv.config as well as other elements

ISV_New_1_199_Billing.style.display = “none” ;

Bye

Calling Asp.NET web service from form onLoad in CRM

This is the code we can make use for calling ASP.NET webservice in form onLoad javascript event handler of our Entity in Microsoft CRM.

This example calls the simple Hello World service and assigns the value returned (i.e. “Hello World”) to a field in the entity form

xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);

xmlHttp.open(‘post’, ‘http://localhost/WebService1/Service1.asmx/HelloWorld’, false);

xmlHttp.send();

var xmlDoc=xmlHttp.responseXML;

var responseElement=xmlDoc.getElementsByTagName(“string”)[0];

var exch=responseElement.firstChild.nodeValue;

crmForm.all.address1_name.DataValue=exch ;

return false;

Check this link for more information

https://nishantrana.wordpress.com/2007/10/18/calling-aspnet-webservice-from-javascript-ajax/

Bye

Calling Asp.NET web service from javascript (Ajax)-(Passing Parameter-POST)

Hi,

Now we will modify the application that we developed in the previous post to work with POST parameter

https://nishantrana.wordpress.com/2007/10/22/calling-aspnet-web-service-from-javascript-ajax-passing-parameter/

We have changed the get to post as we are now not passing the value for Name by appending it in the url.

Only make changes to the function getMessage()

function getMessage()

{

var name=’Nishant’;

xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);

xmlHttp.open(“POST“, “http://localhost/WebService1/Service1.asmx/HelloWorld&#8221;, true);

xmlHttp.onreadystatechange=doUpdate;

xmlHttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”);

xmlHttp.send(“name=”+escape(name));

return false;

}

Let’s understand the changes that we have made

First of all we have change the method of passing data to POST from GET.

But still we need to pass the name’s value which our web service method needs.

For that we’ll modify our Send() method

xmlHttp.send(“name=”+escape(name));

We are using the same name/value pair in send()  which we used at the end of the request URL in the GET version

escape()-It makes sure that the values are valid values i.e. no tricky characters are there.

But this is not enough that is why we added this line

xmlHttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”);

Here the server doesn’t know what kind of data it can expect or is coming from our application.

We are making use of setRequestHeader function to tell the server about the content type we are going to send.

The server can get this information from request’s header that it recieves.

Content-Type  -> Name of the header

application/x-www-form-urlencoded -> http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1

Bye