Showing posts with label Java Script. Show all posts
Showing posts with label Java Script. Show all posts

Sunday, March 01, 2015

HowTo: HTML/JS WebResources

We (developers) have got great feature with CRM 2011 release. If you want to give your CRM application new client side features or controls that are not available OOB on one hand and you want your solution remain supported you have to use HTML/JS webresources. This article will describe approaches, tricks and code snippets I’ve fount or developed during my usage of HTML/JS webresources.

Wednesday, January 07, 2015

HowTo: Open standard lookup window and get selected record(s)

If you are apologist of 100% supported solutions for Dynamics CRM this is a good place to close this article because it describes approach that will allow to open standard lookup dialog window of CRM and get selected values from it. Of course that customization is unsupported.

Friday, June 13, 2014

Dynamics CRM 2013: Step-by-step creating dialog windows

In my previous post I shared how to use Microsoft CRM internal function to show dialog window in Dynamics CRM 2013 inline style. In this post I will write step-by-step guide how to build own dialogs in CRM 2013 style.

Monday, May 26, 2014

Show your dialog in CRM 2013 modal style

With CRM 2013 we have got one working window without any pop-up windows (lookups, dialogs, e.t.c.). But… only for standard features. What to do in case you wanted to use the same approach with modal windows as CRM does it? I walked through SDK and found following article - http://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource. I tried the code but I have got wrapped window.open method. After some investigations I found how CRM does it:
if (typeof Custom == "undefined") {
    Custom = {
        OpenDialog: function (webresource) {
            var $v_0 = new Mscrm.CrmDialog(Mscrm.CrmUri.create(webresource), window, 370, 370, null);
            $v_0.show();
        },
        __namespace: true
    };
}


and usage is following:

Custom.OpenDialog("/webresources/new_webresource.htm");

Demonstration of how it looks like:



You can use this approach but remember that this code uses undocumented methods so it could be broken with any rollup.

Sunday, January 12, 2014

MS CRM 2011/2013: Open new email form with To and Regarding fields prefilled

About a year ago I wrote small article how to open new activity form with Regarding field prefilled.
This week I had a similar task but this time I had to write a JavaScript that will open email form with To field prefilled. So here is the script that you can use:
function OpenEmail(recordid, recordtypecode) {
    var params = "pId=" + recordid + "&pName=&pType=" + recordtypecode;
    params += "&partyid=" + recordid + "&partyname=&partytype=" + recordtypecode;
    var url = "/main.aspx?etc=4202&pagetype=entityrecord&extraqs=" + encodeURIComponent(params);
    url = Xrm.Page.context.prependOrgName(url);
    window.open(url);
}

Here is sample of usage:

OpenEmail("c8576fa9-155e-e311-bbc5-6c3be5a8d218", 2);

This small JavaScript will open new email form with Regarding and To fields prefilled with contact with Id that equals to "c8576fa9-155e-e311-bbc5-6c3be5a8d218".

Sunday, October 27, 2013

Microsoft Dynamics CRM 2013: Actions walkthrough for .Net and JavaScript developers

I believe that almost every developer for Dynamics CRM faced with scenario when he/she had to invoke some complex logic on a server side, pass parameters and receive a response back. Before CRM 2013 we used workarounds similar to this one. Once Dynamics CRM 2013 was released we have got solution that would not require ‘magic’.

Saturday, October 12, 2013

How to turn on Duplicate Detection for client side in Microsoft Dynamics CRM 2013

Microsoft decided to remove Duplicate Detection feature in 2013 version. Why? Not sure.
Following article describes how to restore this functionality.

Tuesday, May 07, 2013

Microsoft Dynamics CRM 2011: Lookup address by ZIP Code

This time I had task to write code that lookups address details (country, state and city) by entered postal code. I will share with my results in this post.

Wednesday, March 13, 2013

Activity Feeds and Exceptions or How to fix something that should work

During work I found following logs in event viewer:

Exception information: 
    Exception type: CrmException 
    Exception message: Could not find a web resource with name Images/refresh.png.
   at Microsoft.Crm.Application.Components.Handlers.WebResource.RetrieveWebResource(String webResourceName, String preview)
   at Microsoft.Crm.Application.Components.Handlers.WebResource.ProcessRequestInternal(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Monday, January 14, 2013

MS CRM 2011: Replacement of textbox with picklist with configurable values

During the work with CRM 4.0 I used this trick to solve similar tasks. Today I had to implement similar functionality and I decided to go supported way – JavaScript + WebResources.

Thursday, January 10, 2013

MS CRM 2011: Open new activity form with ‘Regarding’ field prefilled

I had a task today to open new task form with Regarding field prefilled. Based on SDK description I tried to use following code to accomplish my task:

var params = {
    regardingobjectid: referenced record id,
    regardingobjectidtype: referenced record type name,
    regardingobjectidname: referenced record display name
};

Xrm.Utility.openEntityForm("task", null, params);

Unfortunately this code failed. I’ve started to look for some explanation and I found it in SDK at the same article I’ve mentioned before. Answer was that it is impossible to set values for partylists and regarding lookups.
I knew that this feature works for out of box buttons so I rechecked URL for activities that are created with OOB buttons and reworked code to following which worked without issues:

var params = {
    pId: referenced record id,
    pType: referenced record type code,
    pName: referenced record display name
};

Xrm.Utility.openEntityForm("task", null, params);

Thursday, November 01, 2012

MS CRM 2011: How to refresh Associated or SubGrid from Ribbon button

Today I have got requirement – create custom ribbon button placed to Associated View of entity, execute some logic and invoke refresh of grid. Last point was the trickiest one and that’s why I decided to share with approach how to do it.

Friday, September 07, 2012

MS CRM 2011: How to check user rights on client side

Today I have got requirement to write function which will validate rights of user. In our specific case we had to show/hide buttons on custom web form. I decided to post results of my work here.

Saturday, July 14, 2012

MS CRM 2011: Strange issue with filtered lookup

Today I was working with filtered lookup. Before I had no issues with it but today I faced with strange issue.

Saturday, June 02, 2012

MS CRM 2011: N-N Relationship control: checklistbox style

I have developed WebResource for CRM which displays N-N relation in checklistbox style and decided to share it:

Friday, May 25, 2012

MS CRM 2011: Embed context report to left navigation pane

Idea of this blog post is how to embed report to left navigation pane of Crm editing form. I have found this brilliant post which describes how to embed report into IFrame located on Crm editing form and I took this post as basis for current post.

Saturday, March 03, 2012

MS CRM 2011: Extended handling of Save events in Microsoft Dynamics CRM 2011

About 1.5 ago I wrote post which describes how to work with additional parameters during save of form. I decided to go through all available standard forms and create extended list of available parameters.

Thursday, February 23, 2012

MS CRM 2011: Bulk refresh of user details from AD

When you create user in CRM all the available information is populated from AD into CRM user form. But in case information was changed in AD (email box, phone e.t.c.) - information will remain unchanged till the moment you will open form of user and change it. In case a lot of information was changed it will be quite boring to update users information one-by-one.

Following post describes how to allow bulk update of user details.

Wednesday, February 08, 2012

CRM 2011: Playing with notes control

If you want for some reason to allow/disallow user to insert or edit notes in Microsoft Dynamics CRM 2011 following code can help you:

function FormatNotesControl(AllowInsert, AllowEdit)
{
var notescontrol = document.getElementById('notescontrol');
if (notescontrol == null)
return;
var url = notescontrol.src;

if (!AllowInsert)
url = url.replace("EnableInsert=true", "EnableInsert=false");
if (!AllowEdit)
url = url.replace("EnableInlineEdit=true", "EnableInlineEdit=false");

notescontrol.src = url;
}

function DisableNotesInsert()
{
FormatNotesControl(false, true);
}


Copy script, insert it to webresource, add this webresource to required form and call it during onload/onchange of form. And you should not forget that this script is unsupported because it uses document object and it's methods.

CRM 2011: Creating a Network Path Text Control for Microsoft Dynamics CRM 2011

Following approach is a little bit unsupported so be careful using it.

Create JavaScript webresource, put in it following code, call OnLoad method during loading of form of your entity:

function OnLoad()
{
Transform("new_name");
}

function Transform(fieldid)
{
var c = document.getElementById(fieldid);
if (c == null)
return;

c.style.textDecoration = "underline";
c.style.color = "blue";
c.style.cursor = "hand";
c.ondblclick = function()
{
window.open(Xrm.Page.getAttribute(fieldid).getValue());
};
}


Field has to be simple text type. Replace new_name with field you want to transform. Result for my case: