Field Validations – Adxstudio and CRM Portal

Hello Everyone, As we all know that XRM Model is not supported on Adx and CRM Portal. Therefore we cannot use CRM Forms scripts and Business Rules to perform Client side validation on Portal Entity Forms.

Though we have Entity Form Metadata in Adxstudio and CRM Portal to perform lot of validations but that is also not work for few of cases.

Today in this article I am going to share some Tips and Tricks to play with Custom JavaScript to perform various client side validations on Adxstudio and CRM Portal.

Hide/Show Fields on Entity Forms :


Below are the syntax that you can use to hide/show the entity forms fields (Text, Lookup, Option Set, Date Field etc)
$(document).ready(function(){
// To Hide
$(\”#fieldlabelId\”).hide();
$(\”#fieldvalueId\”).hide();
// To Show
$(\”#fieldlabelId\”).show();
$(\”#fieldvalueId\”).show();
});
or
$(document).ready(function(){
// To Hide
$(\’#fieldlabelId\’).parent().parent().hide();
// To Show
$(\’#fieldlabelId\’).parent().parent().show();
});

Note : Rather Hide/Show Text Field Label and Textbox separately you can use above syntax to Hide/Show the whole Text field control (Label + Textbox)

Enable/Disable Fields on Entity Forms :


Text Field –


$(document).ready(function(){
// Disable the field
$(\”#textboxId\”).prop(\’disabled\’,true);
// Enable the field
$(\”#textboxId\”).prop(\’disabled\’,false);
});

Lookup Field –


$(document).ready(function(){
disableLookup(\’regardingobjectid_name\’, \’regardingobjectid_entityname\’);
});
function disableLookup(LookupNameID, LookupEntityNameID) {
    
    var L_EN_ID = \’#\’ + LookupEntityNameID;
    var L_N_ID = \’#\’ + LookupNameID;
    $(L_EN_ID).next().remove();
    $(L_N_ID).css(\’width\’, \’329px\’);
}

Optionset Field –


$(\’#sw_premisetype\’).prop(\”disabled\”, true);

Hide/Show Section on Entity Forms :


Hide Section –


$(\’table[data-name=\”section_name\”]\’).closest(\’fieldset\’).hide();

Show Section –


$(\’table[data-name=\”section_name\”]\’).closest(\’fieldset\’).show();

Disable/Enable Section on Entity Forms :


Disable Field –


$(\’table[data-name=\”sec_AccountDetails2\”]\’).closest(\’fieldset\’).find(\”input,button,textarea,select\”).attr(\”readonly\”, true);

Enable Field –


$(\’table[data-name=\”sec_AccountDetails2\”]\’).closest(\’fieldset\’).find(\”input,button,textarea,select\”).attr(\”readonly\”, false);

Note : If you get any requirement to make the portal section disables, Rather making it Disable, you must always make it Read-only, because disable section fields values does not store in CRM.
Above syntax is to make the section Read-only instead of Disabled.

Hide/Show Tab on Entity Forms :


Hide Tab-


var tab = $(\’table[data-name=\”section_name\”]\’).closest(\’.tab\’);
var label = tab.prev(\’.tab-title\’);
tab.hide();
label.hide();

Show Section –


var tab = $(\’table[data-name=\”section_name\”]\’).closest(\’.tab\’);
var label = tab.prev(\’.tab-title\’);
tab.hide();
label.show();

Hide/Show Date-time Control on Entity Forms :


Right Click on Date Field Control Textbox and click on Inspect. Now copy the value of \’aria-describedby\’ attribute.

$(\’input[aria-describedby=\”\”]\’).parent().parent().hide();

Above syntax use to Hide/Show Date-Time Textbox Control

Below syntax use to Hide/Show Date-Time Textbox Control

$(\’\’datefield_label\”).hide();

Please feel free to get in touch with me if you want to get advice for some more validations. I\’d love to hear from you.

Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

3 thoughts on “Field Validations – Adxstudio and CRM Portal

  1. How can I show/hide the fields on load? I have tried hiding the fields on entity form load using the code:$(document).ready(function(){$('#firstname').closed('tr').hide();});But the field was shown intially and then was hidden.Is there a way to not show the field at all instead hiding it in the CRM Form Editor?

    Like

  2. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

  3. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: