Showing posts with label Form. Show all posts
Showing posts with label Form. Show all posts

Thursday, October 27, 2016

Get / Set Query string parameters to CRM form.

When using Xrm.Utitliy object to open entity form or Quick create form, sometimes we need to pass query string parameters.
In MS CRM you can enable CRM forms to accept query strings, and you can retrieve those query string parameters in form events.

Set Query string parameters

a.      Go to Entity customization
b.      Open form, where you want to add query strings parameters
c.       Click on Form Properties
d.     In form properties window you will see Parameters tabs.
e.      Add Parameters, which you want to get it, when using openEntityForm or openQuickCreate
f.        When adding parameter need to specify name and data type.

NOTE: In Each parameter name MUST contains at least one underscore (‘_’) character. And name cannot be started with underscore or “crm_”.  Microsoft recommends that you should use solution publisher prefix when defining parameter name, e.g abc_queryString_contactId

g.      We can pass Boolean, Datetime, double, entitytype, Integer, long, PositiveInteger, SafeString, UniqueId, UnsignedInt types of parameters.

Pass Query String parameters to form using openEntityForm or openQuickCreate

openContactForm: function () {
        var parameters = {};
        /*Custom querystring parameter*/

        parameters["qryParam_boolean"] = 0; // Boolean value - 0,1, true, false
        var startDate = new Date();
        parameters["qryParam_datetime"] = startDate.format("MM/dd/yyyy"); // date time
        parameters["qryParam_double"] = 1.0; //double
        parameters["qryParam_eType"] = 2; // Entity Type Code
parameters["qryParam_eType"] = Xrm.Page.context.getQueryStringParameters().etc; // Another way to get Entity Type Code
        parameters["qryParam_integer"] = 100;  //Integer
        parameters["qryParam_long"] = 100000; // Long
        parameters["qryParam_positiveinteger"] = 1; // Positive Integer including 0
        parameters["qryParam_safestring"] = "safestring"; //string
        parameters["qryParam_uniqueId"] =; //GUID
        parameters["qryParam_unsignedInt"] = 1; //unsigned integer

        var windowsOptions = {};
        windowsOptions["openInNewWindow"] = true;

        Xrm.Utility.openEntityForm("new_manufacture",null, parameters,  windowsOptions);

Retrieve Parameters value, when entity form is opened.

To get parameter value, we need to use Xrm.Page.context.getQueryStringParameters()

getQueryStringParamters: function () {
        var booleanParam;
        var datetimeParam;
        var doubleParam;
        var entitytypeParam;
        var integerParam;
        var longParam;
        var positiveintegerParam;
        var safestringParam;
        var uniqueIdParam;
        var unsignedIntParam;

        if (Xrm.Page.context.getQueryStringParameters().qryParam_boolean != null && Xrm.Page.context.getQueryStringParameters().qryParam_boolean != 'undefined') {
            booleanParam = Xrm.Page.context.getQueryStringParameters().qryParam_boolean;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_datetime != null && Xrm.Page.context.getQueryStringParameters().qryParam_datetime != 'undefined') {
            datetimeParam = Xrm.Page.context.getQueryStringParameters().qryParam_datetime;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_double != null && Xrm.Page.context.getQueryStringParameters().qryParam_double != 'undefined') {
            doubleParam = Xrm.Page.context.getQueryStringParameters().qryParam_double;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_eType != null && Xrm.Page.context.getQueryStringParameters().qryParam_eType != 'undefined') {
            entitytypeParam = Xrm.Page.context.getQueryStringParameters().qryParam_eType;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_integer != null && Xrm.Page.context.getQueryStringParameters().qryParam_integer != 'undefined') {
            integerParam = Xrm.Page.context.getQueryStringParameters().qryParam_integer;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_long != null && Xrm.Page.context.getQueryStringParameters().qryParam_long != 'undefined') {
            longParam = Xrm.Page.context.getQueryStringParameters().qryParam_long;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_positiveinteger != null && Xrm.Page.context.getQueryStringParameters().qryParam_positiveinteger != 'undefined') {
            positiveintegerParam = Xrm.Page.context.getQueryStringParameters().qryParam_positiveinteger;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_safestring != null && Xrm.Page.context.getQueryStringParameters().qryParam_safestring != 'undefined') {
            safestringParam = Xrm.Page.context.getQueryStringParameters().qryParam_safestring;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_uniqueId != null && Xrm.Page.context.getQueryStringParameters().qryParam_uniqueId != 'undefined') {
            uniqueIdParam = Xrm.Page.context.getQueryStringParameters().qryParam_uniqueId;
        if (Xrm.Page.context.getQueryStringParameters().qryParam_unsignedInt != null && Xrm.Page.context.getQueryStringParameters().qryParam_unsignedInt != 'undefined') {
            unsignedIntParam = Xrm.Page.context.getQueryStringParameters().qryParam_unsignedInt;
Now you can set value to form or add any logic based on passed parameters.

Tuesday, April 7, 2015

Show all text value for CRM form header attribute

In CRM you can display attributes into form Header, but sometime attribute contains large text, and that text is not properly shown on form header. Part of the text is shaded, and user is not able to see complete value until user mouse hover on that field. 

To show complete text or attribute value you need to change form header formatting.
Default CRM header formatting is three columns.

In my form header I have two attributes and one has large text, so changed formatting for that large text attribute from one column to two columns.

To change formatting for attribute, select attribute and click on change properties button shown on form ribbon.

In Field property window, click on Formatting tab, and select two columns formatting.

Once changed formatting for attribute, rearrange the header attributes.
Save and publish your form and customization. 
Now header is showing complete text / value of attribute

Note: Once you change formatting of header, attributes are become read-only. It is look like a bug in CRM application.
If you want you can vote for this bug on 
So that Microsoft will try to resolve this issue in future release. 

Monday, March 23, 2015

Show Or Hide Entity Image and Navigation Items form Entity Form

For Entity forms don't want to show Entity Image or Navigation items, Microsoft provided this setting in Form Properties.

Open Form in customization,
Click on Form properties.
In Display tab you will see two sections - Page navigation & Image,

Page navigation - Show navigation Items is default checked.. means show navigation items, when any record opened in this form. If you uncheck this checkbox, then navigation items will not be shown.

Image - Show image in Form is also default checked, Entity Image will be shown on form, when it is unchecked, entity image will not be shown for record when this form is used to open record.