Archive for the ‘JScript’ Category

Silverlight application can get a reference to the Xrm.Page Object instance using either of following approaches. 1. Using HTML bridge feature of Silverlight ScriptObject  xrm = (ScriptObject)HtmlPage.Window.GetProperty(“Xrm”); ScriptObject  page= (ScriptObject)xrm.GetProperty(“Page”); 2. Using Dynamic Language Runtime Using DLR you can utilize the dynamic language keywords which allow resolving method calls at runtime. dynamic  xrm = (ScriptObject)HtmlPage.Window.GetProperty(“Xrm”); [...]

Below code shows how to get Security Roles of current User Using JScript which uses a RetrieveMultiple query … function GetCurrentUserRoles() { 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>” + ” <RetrieveMultiple xmlns=\”” + “http://schemas.microsoft.com/crm/2007/WebServices\”>” + ” <query [...]

I had client requirement that on the selection of City (lookup), Region and Sub Region should be populated automatically which is read only field. To achieve this we mapped the city with region (lookup) and sub region (lookup) on the city entity. After writing below code I was getting following error. There was an error [...]

Let me explain the scenario.. We have a Model lookup and a variant Lookup on Lead form. Every variant is associated with a particular model. i.e One model have multiple Variant. Eg. Model          Varient Alto             Alto LX Alto             Alto Xcite Alto             Alto LXI SX4               SX4 VXI SX4               SX4 ZXI Leather SX4               SX4 ZXI —————————- Now [...]

You can just open the Advanced find page and build the query as you like. Then run the query to see if it returns the data as you wish it should. If you are satisfied with the results and you want to know what query was sent into the CRM Framework, then press F11 to [...]

Create record using JScript This sample shows how to use the CrmService.Create method using the same example provided in the Server Programming Guide: CrmService.Create method. To test this sample: Paste the following code into any Event Detail Properties dialog box. Save the form and then click Create Form on the Preview menu. When the event [...]

Run a workflow through JavaScript /* the function */ 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>” + [...]

How to show the Advanced Find result view in an IFrame? Instead of building a custom aspx page (dynamically passing parameters, see Adi’s solution), another method to share if you don’t need passing parameters into the query. 1. Build your Advanced Find query and save it, then copy the Shortcut. 2. Put a IFrame control [...]

It’s a common requirement to show entity’s associated view (1:N, N:N) in IFrame, the below code works for both 1:N and N:N relationship, it also works on both On-Premise and IFD deployment. All you need to do is find out (IE Developer Toolbar) the ID of the associated link. The 1:N relationship needs these parameters [...]

CRM MVP Batistuta Cai already had a post about a plug-in solution. If the lookup entity is a system entity, you can also use this technique: Let’s start from an example: you have a custom entity call: MyEntity, you have setup a N:1 relationship between MyEntity and Opportunity, so the user can see an opportunity [...]