Call CRM 2013 Modal window for webresources

we had requirement to implement CRM 2013 look alike modal window for some webresources. Following code can do the needful:

var DialogOption = new Xrm.DialogOptions;
DialogOption.width = 500; DialogOption.height = 420;
Xrm.Internal.openDialog(“Web Resource path”,
DialogOption,
null, null,
CallbackFunction);
function CallbackFunction(returnValue){ }

In our case, we needed custom UI like below:

image

Hope it helps!

{Workaround} Configure Views for showing records under specific Business Process : Dynamics CRM 2013

We had requirement to classify Opportunity Views as per Process Name, for e.g. Opportunity under Opportunity Sales Process, Opportunity under Sales Process 1. Following is the workaround used. First create a field to be used to store Process Name (in my sample below I am using Description field)

Go to Settings->Process and create a new sync Workflow as described below:

clip_image002

Assign Record fields change as below:

clip_image003

Write update step and select Opportunity entity, Here I am updating Description field with Related entity Process Stage (Process):

clip_image005

Description field will now store Process Name.We are done with populating the text field, now just need to create Views on this field and we are done.

Finally, Views will be similar as below screenshot:

clip_image007

Configure Views for showing records under specific Business Process Stage : Dynamics CRM 2013

We had requirement for showing Views on Opportunity based on stages, e.g, Opportunity in Qualify stage view should only show Opportunities under Qualify stage. For this we implemented in following manner:

Go to Default public view of Opportunity under Settings->Customizations->Entity->Opportunity->Views:

clip_image002

Click Save as fill in the name as below:

clip_image004

Screen will appear as below:

clip_image005

Click on Edit Filter Criteria and select related entity Process Stage, select criteria as in below screenshot:

clip_image006

Click ok, Save and publish this opportunity, Go to Sales->Opportunity, View will display opportunity only under Qualify stage now:

clip_image008

Hope it helps!

Get Attribute Logical Name from Display Name: CRM 2011 and CRM 2013 On-Premise\IFD using query

Recently wanted to get logical names of 25 columns at one go. Business analyst provided us with display names. One colleague of mine quickly told me about a workaround from database to read all at one go

Select ll.Label, Attr.LogicalName From LocalizedLabelAsIfPublishedView ll

INNER JOIN Attribute attr

ON ll.ObjectId = attr.AttributeId

INNER JOIN EntityView ev ON ev.EntityId = attr.EntityId

WHERE ev.ObjectTypeCode = EntityTypeCode and ll.ObjectColumnName in (‘DisplayName1’,

‘DisplayName2’)

CRM 2013 Create Email error – Cannot open Sql Encryption Symmetric Key because Symmetric Key password does not exist in Config DB.

We were trying to send email using workflow but were getting following error: Cannot open Sql Encryption Symmetric Key because Symmetric Key password does not exist in Config DB.

When we checked we found that we need to enable data encryption on CRM in order to create email message in CRM.

Go to Settings->Data management –> Data Encryption

image

Fill encryption key in the screen like below:

image

Hope it helps!

Function to show Business Process Area expanded on form

In CRM 2013 forms, Business Process Area is collapsed by itself during form type create. So we wrote explicit code on form load to achieve the same.

var formType = Xrm.Page.ui.getFormType();
var CREATEFORMTYPE = 1;

function onLoadBusinessProcessExpand() {
    var businessProcessArea = $(‘#processControlCollapsibleArea’);
    if (formType == CREATEFORMTYPE && businessProcessArea != null) {
        $(‘#processControlCollapsibleArea’).css({ display: “block” });
    }
}

 

onLoadBusinessProcessExpand function needs to be called on form load.
Hope it helps!

Refresh CRM 2013 Form using script

Sometimes we have to refresh CRM form using script. Till 2011 following script used to work fine:

window.location.reload(true);

But the following code was not working fine when we wanted to reload the page during save so we implemented following way:

A note here on successcallback and errorcallback methods can be found here:http://thedynamicscrmblog.wordpress.com/2013/12/04/crm-2013-client-api-save-refresh/

Xrm.Page.data.save().then(successCallback, errorCallback);

Xrm.Page.data.entity.save();

funtction successCallback()

{

//Needed to set form dirty to false explicitly as it is not done by platform

Xrm.Page.data.setFormDirty(false);
var Id = Xrm.Page.data.entity.getId();
Xrm.Utility.openEntityForm(“opportunity”, Id);

}

function errorCallback(attr1,attr2)

{

}

Hope it helps!


Check this out

Trying to Learn Dynamics CRM: Download!

Learn Dynamics CRM App on Google Play store

Lock CRM 2013 Form using script along with locked panel in footer

We had a requirement to lock CRM 2013 form on some condition and it should appear locked.We implemented following code to achieve

the same.(Mix of supported and unsupported scripting)

Below are functions to lock field:

function disableFields(flag) {

    Xrm.Page.ui.controls.forEach(function (control, index) {
        if (doesControlHaveAttribute(control)) {
            control.setDisabled(flag);
        }
    });
}

function doesControlHaveAttribute(control) {
    var controlType = control.getControlType();
    return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;
}

Function needs to be called as below to disable form:

//Code to disable fields
disableFields(true);

$(“#footer_statecode”).find(“span”).each(
function () {
    var sval = $(this).text();
    if (sval == ‘Open’) {
        $(this).text(“Locked”);
    }
}
);
$(“#savefooter_statuscontrol”).hide();

This will disable CRM 2013 form like mentioned below:

image

Notice in the above image that there is a lock panel visible below the form.

Following code to enable form fields back:

//Code to enable fields
disableFields(false);

$(“#footer_statecode”).find(“span”).each(
function () {
    var sval = $(this).text();
    if (sval == ‘Locked’) {
        $(this).text(“Open”);
    }
}
);
$(“#savefooter_statuscontrol”).show();

Hope it helps!