This Dynamics 365 CE blog is all about offering you insights and solutions on Customer Engagement, Power Automate, PowerApps, and Dataverse. Stay ahead of the curve with our actionable advice and unlock the full potential of Dynamics 365 CE for your business.
Thursday, March 21, 2013
How to save read-only fields in CRM 2011
Wednesday, June 10, 2009
Filtering Lookups in CRM 4
- On the forms OnLoad event write the following code.
FilterLookup = function(source, target)
{
if (IsNull(source) || IsNull(target)) { return; }
var name = IsNull(source.DataValue) ? '' : source.DataValue[0].name;
target.additionalparams = 'search=' + name;
}
- On the OnChange event of the Parent Account lookup mention the below code.
FilterLookup(crmForm.all.parentaccountid, crmForm.all.primarycontactid);
- Settings > Customization > Customize Entites > Contact > Forms & Views > Contacts Lookup View
- Click on Add Find Columns on the right
- Tick Parent Customer
- Click OK and Publish



Thursday, May 28, 2009
Stop CRM Form Save
- event.returnValue = false; or
- return false;
Code : event.returnValue=false; alert('You clicked Drive C.');
Code : return false; alert('You clicked Drive C.');
Tuesday, May 12, 2009
Hide / Unhide CRM Form Tabs
crmForm.all.account.tab1Tab.style.display = "none";
My intend is not to convey how to hide a tab [I just did ;)] but also why "tab1Tab"?
I suggest you to have a look at the HTML source on the Account form IE8 > Page > View Source, You'll notice that the tabs have an ID on them (which go tab0Tab, tab1Tab, tab2Tab,........). We just refer them and then use JavaScript's CSS properties to achieve the result.
Thursday, March 12, 2009
Using window.opener to refer to Parent CRM window's field
Even though it is a little JavaScript but the challenge here is to know if the parent window is the one YOU are looking for?
So here is a little chunk of code that confirms you the Parent Window.
if(window.opener) //checks if current window has a parent window
{
var oParentForm = window.opener.parent.document.getElementById('crmForm');
if(oParentForm) //This confirms if the parent window is a CRM form
{
// Now try to access a field in the parent form
// like name attribute in Account entity
if(oParentForm.all.name) //This ensures you have reached the form you're looking for
{
// Proceed with your code
}
}
}
There could be other methods too, like checking the Object Type Code of the parent form instead of the 'name' field.
More ideas are welcome, don't hesitate, but share.
Saturday, October 11, 2008
Javascript - Know how v1.0?
What just happened is I had this little snippet below the "Click Here - Protocol" Button.
alert(window.location.protocol);
To know who is hosting my blog:
The executing code under "Click Here - Hostname" button is.
alert(window.location.hostname);
Application :- When we open an AJAX call from within CRM, we can generate the URL like this:
{
var Protocol = window.location.protocol;
var HostName = window.location.hostname;
var sURL = Protocol+'//'+HostName+'/webservice.asmx';
}
at runtime and pass it this way:
xmlHttp.Open('POST',sURL,true);
A useful piece of information I use it often now.
Friday, September 12, 2008
Passing CRM Form values to an IFrame
I assume that you have already added an IFrame to the entity amd unchecked "Restrict cross-frame security" under IFrame properties > Security section
PASSING SINGLE PARAMETER TO AN IFRAME :
- new_customfield1 - Schema name of my custom field.
- IFRAME_Custom - Name of the IFrame.
Snippet (You may place it on OnLoad or OnChange of the CRM Form as per your requirements)
var CustomFieldValue = crmForm.all.new_customfield1.DataValue;
crmForm.all.IFRAME_Custom.src = 'http://localhost/YourURL.aspx?value='+CustomerFieldValue.
PASSING MULTIPLE PARAMETERS TO AN IFRAME :
- new_customfield1 - Shema name of first custom field.
- new_customfield2 - Schema name of the second custom field.
- IFRAME_Custom - Name of the IFrame.
Snippet
var CustomField1 = crmForm.all.new_customfield1.DataValue;
var CustomField2 = crmForm.all.new_customfield2.DataValue;
crmForm.all.IFRAME_Custom.src='http://localhost/YourURL.aspx?value1='+CustomField1+'&value2=' + CustomField2;
Tuesday, August 5, 2008
Apply colors to CRM form labels
Write this code snippet on OnLoad Event of the form:
var str = "";
str += "First Name";
str += "<SPAN style='color:blue'> Only for info. </SPAN>";
crm_form_label.innerHTML = str;
Happy coloring form labels!!
Wednesday, May 21, 2008
Displaying CRM 4.0 form field and tab
crmForm.all.new_field_c.style.display = "inline";displays the label and
crmForm.all.new_field_d.style.display = "inline";displays the TextBox.
Similarly to display a tab use
crmForm.all.tab1Tab.style.display = "inline";
Note: These are unsupported customizations.
Hiding CRM form fields and tabs
These apply to Microsoft Dynamics CRM 4.0. Note - These are unsupported customizations and may not work on CRM Upgrades.
Avoiding Scenarios where you can apply this functionality, I am just getting down to it. Depending on your requirement you may want to do one of these.
Let me take one at a time:
Hiding CRM form field:
Suppose that field's schema name is "new_field".
This is used to hide the textbox
crmForm.all.new_field_d.style.display = "none";
Use this to hide the Label
crmForm.all.new_field_c.style.display = "none";
Note '_d' and '_c', they are important.
Hiding CRM tabs:
The General tab is common to all and you may never want to hide this tab. The custom tab(s), the one right next to the general tab takes the value "tab1Tab", next to this on the right takes the value "tab2Tab" and so on.
Apply this nugget to hide the 1st tab next to the general tab.
crmForm.all.tab1Tab.style.display = "none";
This is about hiding them, just in case you want to seek them.
Wednesday, April 30, 2008
Stop the save event
Case example - You are validating some data on the form and if the data is incorrect the save event must stop and retun back to the form rather than alerting the fault on the form and continuing saving the form. The OnSave event should return a "false" value to avoid the form from saving. This can be achieved by writting the following nugget.
event.returnValue = false;
To continue saving the CRM form you may want to use this
crmForm.Save();
or
crmForm.SaveAndClose();
Ronald Lemmen has given a few more nuggets. Also going through the SDK would give you an advantage. Plenty of them available.
Happy Scripting..|/
Wednesday, March 5, 2008
Disable a Crm Form field
Does the below shown crm field appear disabled? Yes. Well, this is how you can achieve it at run time.
Code 1:
crmForm.all.prefix_entityname.Disabled = true;
Does the below shown crm field appear disabled? If your say is no. You are of course right. It does not look disabled, indeed it is.
And this is how you achieve it.
Code 2:
crmForm.all.prefix_entityname.disabled = true;
So, disabling a crmform field can take two different views as shown above.
Carefully admiring the code you will notice the difference.
Code 1: Capital D, Disabled
Code 2: Small Letter d, disabled.
Happy disabling crm form field.