Wednesday, July 28, 2010

Calling Custom Workflows In Javascript or ISV

If we want to calll Custom workflow with in CRM 4.0 javascript or ISV we call CRM 4.0 inbuilt function "launchOnDemandWorkflow" in this methods we can pass object ID and Workflow ID launchOnDemandWorkflow('',ObjectTypeCode,Workflow ID)

We simply get ObjectTypeCode from crmForm.Objectid and workflow is unigue ID we can get from Workflow section. the problems is that when we call this launchOnDemandWorkflow it will frompt workflow dialog box for our confirmation after that we can't put notification whether that workflow Successed or not. in this can we can remove this pfompt box and we can put custom confirmation message and success message.


/********************* Calling Custom Workflows ************************/
//Pirasanth
ExecuteWorkflow = function(entityId, workflowId)
{
var xml = "" +
"<?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\">" +
GenerateAuthenticationHeader() +
" <soap:Body>" +
" <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <Request xsi:type=\"ExecuteWorkflowRequest\">" +
" <EntityId>" + entityId + "</EntityId>" +
" <WorkflowId>" + workflowId + "</WorkflowId>" +
" </Request>" +
" </Execute>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/MSCrmServices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
return(resultXml.xml);

}

/*************************Calling Web Services****************************/


this Wrokflow dialog box promf for confirmation if we press ok then ll execute the workflow bt user doesn't know this workflow successed or not..user can check from workflow section bt not ll promf


so in this case we can put custom confirmation messagebox and after scuuessed we can put notificatiopn whether theis workflow successed or no..
for the confirmation message we can put

Success Message..

Here user could understand whethere this workflow successed or not

Thursday, June 3, 2010

Filtered Lookup in CRM 4.0

How to create Filtered lookup in CRM 4.0

First of all you need to remote login to that server where CRm hosted after that go IIS root "C:\inetpub\wwwroot\_controls\lookup" then open the "lookupsingle.aspx" file and pase the below code in this aspx file .

<script runat="server">

protected override void OnLoad( EventArgs e )
{
base.OnLoad(e);
crmGrid.PreRender += new EventHandler( crmgrid_PreRender );
}

void crmgrid_PreRender( object sender , EventArgs e )
{
if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith ("<fetch>"))
{
crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);
crmGrid.Parameters.Remove("searchvalue");
this._showNewButton = false;
}
}

</script>

For the main look up onchange event write below code

crmForm.all.ias_cityid.lookupbrowse = 1;
crmForm.all.ias_cityid.AddParam("search", "<fetch mapping="logical"><entity name="ias_cityEntity"><all-attributes><filter type="and"><condition value="'" operator="eq" attribute="ias_countryid"><condition operator="in" attribute="statecode"><value>0</value></condition></condition></filter></ALL-ATTRIBUTES>");</entity></fetch>

//remove the child lookup value
crmForm.all.ias_cityid.DataValue=null; // child lookup

// ias_cityEntity -- child lookup entity
// ias_country_id -- main lookup id
// ias_countryid -- main lookup attribute in sub entity
// ias_cityid -- sub lookup entity

Monday, March 22, 2010

Calling WCF Restful Services in Jquery

Create WCF 2010 Restful Services



Visual studio 2010 produce some online template so we can download this template and use from this online template we can get WCF REST Service Template 40(CS)

Just go to New Project - Online Templates - get WCF REST Service Template 40(CS) from this we can download restful service template. Once we download it will come under WCF directory.



Solutions look like this.







In this service1 class contain default methods some methods contain WebGet and WebInvoke. If we use WebGet work methods as get if we use WebInvoke we can specify methods as PUT, POST, DELETE depending on the situation we can use either WebGet or WebInvoke.



I wrote methods to return list of student details. Here UriTemplate is the URL for access this methods and response methods as JSON because I need to call this methods in Jquery so I use JSON format. Body style is not mandatory

<pre class="brush:html">

[WebGet(UriTemplate = "StudentsJSON",BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]

Public List<Student> GetStudentCollectionJSON()

{

return new Student().getStudent();



}



Main advantage of this REST in 4.0 is we can give unique URL for each method and in WCF there is no .SVC extension. Microsoft has removed this SVC extension.



From below URL we can see all the methods here there is no .svc extension

http://localhost/Test/TestService/help









Calling WCF Restful Services in Jquery



Before discuss about calling WCF Restful Services through Jquery we need to understand what is REST? Why we need to use restful services? When Microsoft introduces this REST and Restful services? Why we need to away from ASMX, WCF using SOAP base protocols? So here I am not going to explain the theory we can get to know by googling.



If we navigate through the methods “GET” we will get XML, JSON format default data







If we use http://localhost/Test/TestService/StudentsXML link we will get XML format data









[WebGet(UriTemplate = "StudentsXML" , ResponseFormat = WebMessageFormat.Xml)]

public List<Student> GetStudentCollectionXML()

{

return new Student().getStudent();

}

Using http://localhost/Test/TestService/StudentsJSON link we will get JSON format data





[WebGet(UriTemplate = "StudentsXML" , ResponseFormat = WebMessageFormat.Xml)]



public List<Student> GetStudentCollectionXML()

{

return new Student().getStudent();



}



//Pirasanth

Wednesday, February 10, 2010

CRM 4.0 Javascript Intellisense Tool

I faced lot of problem when i create javascript in crm. because in crm there is no javascript intellisence and visual studio 2008 also have javascript intellisense but not CRM related things, so i need to remember all the syntax and also have to type correct variables. but resently i have found javascript intellisense tool from this we can easily create javascript stuff with intellisense
download tool

You can download tool

Thursday, February 4, 2010

how to call wcf service from jquery

Here I have mentioned how to call WCF using JQuery......

First of all I have created WCF service library using visual studio 2008.Then I have added assembly reference “System.ServiceModel.Web” to my WCF library.Then import this assemply to out interface like this way “using System.ServiceModel.Web;”then declare methods in this interface


[OperationContract]

[WebInvoke(Method="POST",BodyStyle=WebMessageBodyStyle.Wrapped, ResponseFormat=WebMessageFormat.Json)]


string GetData(string value);


After that implement this methods to my class and also create new end point to accress jquery.



WCF Services Test

After that I want to access this WCF to my client application. To my client application import JQuery library to my application. Then put the reference to my page in this way





 







From this code you can able to access WCF in client side.

calling WCF Services vai JQuery

Friday, January 8, 2010

How to call web service using jquery

<script type="text/javascript">
function TestMethod1()
{
$.ajax(
{
type: "GET",
url: "http://localhost/DD/WebService1.asmx/HelloWorld",
data: "{}",
contentType: "application/json",
dataType: "json",
async: false,
cache: false,

success: function (result) {
alert(result.d);
},
error: function ()
{ alert(&quot;Unavailable&quot;); }
});
}
</script >

Wednesday, January 6, 2010

Miling Amma and Bhagavan

Question: Nobody in this world is free of sufferings. To be free from sufferings what should be done?
Sri Bhagavan: That is very simple. Please follow seven truths to be free from suffering.
1. Everything comes from a single source. It could be God or Energy. There is no beginning and end to life.
2. If you identify this source, you'll not differentiate between good, bad, right or wrong. All these things are our views. Everything came from one source.
3. Life is nothing but your search for "SELF". In your life, things that happen to you, people you see, everything reflects your "Self". If you are suffering from poverty, it means there something wrong within yourself. You have to correct this to get out of poverty. If you have hatred, then who ever you see will exhibit the same quality. If you have evil thoughts, people you meet will also have evil thoughts. Try to understand yourself first.
4. Realize that anything you experience in this Life is by God's grace. Supposing you slip while walking, try to realize that as God's grace too. If you see God in everything, your life will become wonderful.
5. Realize that anything you experience in this Life is just a "test" for you by God. It is not a bad experience. If it is considered as a bad experience then it would mean that God is not compassionate. If you experience a problem, consider it an opportunity for you to face it and come out of it. You've been given people, wealth and confidence to face challenges. If you understand this, your confidence will improve. Just to test your confidence God gives you a test.
6. If you realize that anything you experience is a test for you by God, then you'll be able to think deep about the problem and handle it in a better way. You'll understand its result. Then you'll have no fear.
7. If you understand the above 6 truths, then there will be an enormous transformation in your body. From then on, you'll not only have compassion, but you'll become that "compassion".

Thank You AMMABHAGAVAN

Tuesday, January 5, 2010

Yoga

யோகாசனம் பற்றிய சில குறிப்புக்கள்

Amma Bhagavan's Songs