Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, March 7, 2011

Use of Web Resources in CRM 2011

With CRM 2011, you now have the concept of including resources within CRM that can they be used to display on CRM forms in IFRAMES and buttons and other customizable objects in CRM.

A web resource in CRM can be any of the following


Here we take an example of adding a custom html page that requires supporting javascript and images for it to work.

When you would have designed the page, there are chances that you have created a directory structure where the htm page would be in the root directory but the images would be in a folder called _img and scripts in a folder called scripts within the root directory.

To upload this entire application as resource within CRM, you will need to individually upload all of the files related to the application. However, what you need to take care is the way you name these resources in CRM while uploading. You can create a virtual directory structure by including the path in the name of the resource.

In case of our above example, the resources would be named as follows to represent the same directory structure

Suppose if you have created the following web resources.
1. New_/IMG/My.GIF
2. New_/Script/My.js

Now if you are going to use these webresources in the html web resource and the html web resource name is “new_/Pages/TestHtmlPage.html”.
Then you need to give the name as follows, because CRM takes the name as the virtual folder. Hence your script files exist in the Script folder and Html page exist in the Pages folder hence when you add the resources in your html page then first you come out from the “Pages” folder and then you give the path for the js file hence the src will be “../Script/My.js”.
< SCRIPT src=” ../Script/My.js” type =text/javascript>

Say you are developing an htm page from which you are going to create an account in CRM or need to access the controls placed on the CRM entity form, you will need to add the reference to the following script library and also ensure that you have uploaded this as a resource in CRM as well.
Once the resources have been added in CRM, you can now access them in CRM through IFRAME.


Saturday, February 19, 2011

Difference between CRM 4.0 and CRM2011 script for using on form customization

When working with CRM2011 Java script we found many difference about syntax/methods between CRM2011 and CRM4.0 Please check some of the comparisions we have listed. Please click on the Image below to enlarge view.

Tuesday, November 23, 2010

Debug script in Microsoft Dynamics CRM

In Internet Explorer 8 (IE 8 )Microsoft provided a way to debug the scripts.

With Internet Explorer 8 and JScript Libraries, debugging scripts has become much easier. To debug the script, Please follow the step below.
  1. When working with Microsoft Dynamics CRM try to reproduce the conditions where an error is occurring press F12 to open the Internet Explorer developer tools.


  2. On the Script tab, to the right of the Start Debugging button, use the drop-down to locate your JScript library.


  3. Set a breakpoint by clicking on the left margin within your function.

  4. Click Stop Debugging to stop debug.


  5. If your script is in the Onload event, you may need to select the Microsoft Dynamics CRM window and press F5 to reload the window.
For more information, see the MSDN topic Debugging Script with Developer Tools. http://msdn.microsoft.com/en-us/library/dd565625(VS.85).aspx

Hope this helps!

Friday, August 28, 2009

How to convert a RetrieveMultiple query written Server side to SOAP message to be used in Javascripts

It has often been seen that a RetrieveMultiple query that is very easy to write using the server side Query Expression objects using CRM webservices becomes difficult to achieve if we need to create a SOAP message for the same.

In this article we hope to explain each of the elements involved in the writing of SOAP messages to be used through Javascripts.

Let us take a simple RetrieveMultiple code as an example.

While writing the SOAP message the first component required is the SOAP envelope. This is the same at all times for all SOAP messages.

"<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+

Next we need to add the Authentication Header that needs to be passed along with the SOAP message for successful authentication with the CRM Web service. CRM has an inbuilt function GenerateAuthenticationHeader() that can be used for this purpose.

var authenticationHeader = GenerateAuthenticationHeader();

SOAP Body is where the actual SDK message to be executed is included.

"<soap:Body>"+

In our example we are using the RetrieveMultiple Message so we provide the Message name and the schema reference to the CRM webservices

"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+

The parameter to a Retrieve Multiple Message is always a query expression

QueryExpression query = new QueryExpression();

"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+
" xsi:type='q1:QueryExpression'>"+


Now include all properties of the Query object that you set.

Entity name

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

"<q1:EntityName>incident</q1:EntityName>"+

Column Set

query.ColumnSet = new AllColumns();

"<q1:ColumnSet xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>title</q1:Attribute>"+
"<q1:Attribute>incidentid</q1:Attribute>"+
"</q1:Attributes>"+
"</q1:ColumnSet>"+

Criteria

ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "title";
condition.Operator = ConditionOperator.Like;
condition.Values = new string [] {strSearchText};

"<q1:Criteria>"+
"<q1:FilterOperator>And</q1:FilterOperator>"+
"<q1:Conditions>"+
"<q1:Condition>"+
"<q1:AttributeName>title</q1:AttributeName>"+
"<q1:Operator>Like</q1:Operator>"+
"<q1:Values>"+
"<q1:Value xsi:type='xsd:string'>"+searchtext +"</q1:Value>"+
"</q1:Values>"+
"</q1:Condition>"+
"</q1:Conditions>"+
"</q1:Criteria>"+

Here, we have used 'Like' condition operator, likewise one can use any of the sdk supported operators and change the values to be matched accordingly.


Order by

OrderExpression oe = new OrderExpression();
oe.AttributeName = "title";
oe.OrderType = OrderType.Ascending;
query.Orders = new OrderExpression[]{oe};

"<q1:Orders>" +
"<q1:Order>" +
"<q1:AttributeName>title</q1:AttributeName>" +
"<q1:OrderType>Ascending</q1:OrderType>" +
"</q1:Order>" +
"</q1:Orders>" +

Once you have set all of these… your SOAP message is ready for execution.