jump to navigation

Microsoft Dynamics CRM 4.0 Accessing Parent Form July 28, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , ,
add a comment


In some cases you made need to have a code fire based on information from the parent form of that entity. For example, lets say you have a checkbox on the Order form that has values “Approved” and “Unapproved”. You need to have the Product lookup field disabled on the Order Product entity if the value “Unapproved” is checked. This is just an example, there are many other scenarios where this might come in handy. Place this code onload of the child entity.

if (
(window.opener != null) &&
(window.opener.parent != null) &&
(window.opener.parent.document != null) &&
(window.opener.parent.document.crmForm != null)) {

var parentForm = window.opener.parent.document.crmForm;
var formType;

switch(parentForm.FormType)
{

case 1:
formType = “Create Form”;
break;

case 2:
formType = “Update Form”;
break;

case 3:
formType = “Read Only Form”;
break;

case 4:
formType = “Disabled Form”;
break;

case 5:
formType = “Quick Create Form”;
break;

case 6:
formType = “Bulk Edit Form”;
break;

default:
formType = “Undefined Form Type”;
break;
}

if (parentForm.ObjectTypeName == “PARENTENTITY”)
{

if(parentForm.all.FIELD.DataValue == VALUE)

{
//PLACE FUNCTION FOR CHILD ENTITY HERE

}

}
}

Enjoy!

For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Microsoft Dynamics CRM 4.0 Setting field requirement level with jscript July 23, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , ,
add a comment


Sometimes it is necessary to change a field’s requirement level after the action of something else. Lets say you have a picklist called Contact Method, and one of those values is “email”. Once the user selects email, you want the email field to now become a required field so he/she doesn’t accidentally forget to put in the email address. However, the user may select the value “phone”. You then wouldn’t want the email address to be required because its not applicable, the phone field is what you want required. The point is, you need the field to become required when a particular value is selected, not all the time. Place this line of code onchange of the field you want to trigger it. Replace “fieldname” with the name of your field you want to set the requirement level on.

crmForm.SetFieldReqLevel(“fieldname”, 1);

Enjoy!

For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Microsoft Dynamics CRM 4.0 Hiding taskbar buttons July 22, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , , , ,
5 comments

In many occasions you may need to hide a task bar button on a form, lucky for you i’m going to show you how. Im also going to show those of you that do not know how to use the developer tool bar to grab the name of the button you are wanting to hide. In this example i am going to hide the “Create Invoice” button on the Order.  First open an exsisting order and press ctrl N. You now have the option to go to your developer tool bar. Upper right hand corner click tools, then developer tool bar.

 Once the dev toolbar has finished loading go to find, select element by click. Put your mouse over the button you want to hide, you will notice a blue outline over the button. Click that button and the properties of that button come up on your dev toolbar. Look for you button and you will see the ID for it.  You can hide the button in many different scenarios but for a simple example i am just going to hide it when the form loads. Place the following code onload.

var CreateInvBtn=document.getElementById(‘_MBprocessOrder’);
if(CreateInvBtn!=null)
            CreateInvBtn.style.display=’none’;

_MBprocessOrder is the ID of the button i am hiding in this example, for those that are hiding a different button replace that with your button ID. When you want to have the button show again use the following code:

var CreateInvBtn=document.getElementById(‘_MBprocessOrder’);
if(CreateInvBtn!=null)
            CreateInvBtn.style.display=’inline’;

Enjoy!

For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Microsoft Dynamics CRM 4.0 disabling all fields on a tab July 14, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , ,
add a comment

Ever need to disable all fields on a tab not just one or two? Want to know a quick way of doing it instead of crmForm.all.field.disabled = true; for every field? Of coarse you have or you wouldn’t be here :).

Onload

function disableTab(tabIndex)
{
var tab = document.all[“tab” + tabIndex];
for (var i = 0; i < tab.all.length; i++) {
if (tab.all[i].Disabled !== undefined) {
tab.all[i].Disabled = true;
}
}
}
disableTab(2);

Just replace the “2” in disableTab(2) with the proper tab number

Hope this helps!

For more information about Dynamics Four or to contact us please visit http://dynamics4.com

Microsoft Dynamics CRM 4.0 Primary Contact Filter July 14, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , ,
add a comment

I have received quite a few requests to have primary contact on accounts, when clicked, only show the contacts for that particular account. For those that may already have some sort of look up filter in place they may have experienced this problem, and for those that don’t, well here is a solution that will work. When in an account with a “&” in the name, you click primary contact and you receive an error. Here is a fix for that.

Account Onload:

if (crmForm.FormType == 2 && crmForm.ObjectId != null)
{
var name = crmForm.all.name.DataValue;
crmForm.all.primarycontactid.additionalparams =  ‘search=’ + name.replace(“&”,”%26″).replace(“+”,”%2b”);
}
Hope this helps!
For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Microsoft Dynamics CRM 4.0 hidden fly-out menu’s December 15, 2009

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , ,
add a comment

 Today i was presented with an issue with fly out menus being hidden behind the main menu in Microsoft Dynamics CRM. 

I was told this issue is being addressed in Rollup 9, obviously i couldnt wait for that. So i figured out a workaround for that, follow these steps and it will resolve the issue. In IE go to tools/internet options/security tab/local intranet/sites/advanced/add your crm url in the box/save.

Hopefully this will save you some headaches!

For more information about Dynamics Four or to contact us please visit:

http://www.dynamics4.com

Setting a default value on a lookup field in Microsoft Dynamics CRM 4.0 October 27, 2009

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , ,
8 comments

d4 logo I got a request to set the “Unit” on an Opportunity Product to always default to “Primary unit” when a product is created. Setting default values on lookup fields seems to be a common request, so i decided to post the code to achieve this. This is an Onload Event.

//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
   var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
   lookupItem.id = ‘{299F37C4-6D9D-4628-ADF9-9479A6F209BA}’;
   lookupItem.typename = ‘uom’;
   lookupItem.name = ‘Primary Unit’;
// Add the object to the array.
   lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
   crmForm.all.uomid.DataValue = lookupData;

If you want to use this code for other lookups, here is what you need to change:

//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
   var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
   lookupItem.id = ‘{Fields Guid}’;
   lookupItem.typename = ‘Entity Name’;
   lookupItem.name = Lookup Value;
// Add the object to the array.
   lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
   crmForm.all.FieldName.DataValue = lookupData;

Enjoy!!

For more information about Dynamics Four you can contact us at http://www.dynamics4.com

Hiding multiple tabs based on picklist value in Microsoft CRM 4.0 October 5, 2009

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , ,
add a comment

d4 logoBeing able to hide tabs until a certain value is selected in a picklist is becoming a common request. So i decided to post how you can accomplish that. Apply this code on the onload and onchane events (replace with your field names).

if
(crmForm.all.new_fieldname.DataValue == 1)
{
crmForm.all.tab1Tab.style.display = ‘none’;
crmForm.all.tab2Tab.style.display = ‘none’;
crmForm.all.tab3Tab.style.display = ‘inline’;
crmForm.all.tab4Tab.style.display = ‘inline’;
crmForm.all.tab5Tab.style.display = ‘none’;
crmForm.all.tab6Tab.style.display = ‘none’;
crmForm.all.tab7Tab.style.display = ‘none’

}

else if
(crmForm.all.new_fieldname.DataValue == 2)
{
crmForm.all.tab1Tab.style.display = ‘none’;
crmForm.all.tab2Tab.style.display = ‘none’;
crmForm.all.tab3Tab.style.display = ‘inline’;
crmForm.all.tab4Tab.style.display = ‘none’;
crmForm.all.tab5Tab.style.display = ‘inline’;
crmForm.all.tab6Tab.style.display = ‘none’;
crmForm.all.tab7Tab.style.display = ‘none’

}
else if
(crmForm.all.new_fieldname.DataValue == 3)
{
crmForm.all.tab1Tab.style.display = ‘none’;
crmForm.all.tab2Tab.style.display = ‘none’;
crmForm.all.tab3Tab.style.display = ‘inline’;
crmForm.all.tab4Tab.style.display = ‘none’;
crmForm.all.tab5Tab.style.display = ‘none’;
crmForm.all.tab6Tab.style.display = ‘inline’;
crmForm.all.tab7Tab.style.display = ‘none’

}
else if
(crmForm.all.new_fieldname.DataValue == 4)
{
crmForm.all.tab1Tab.style.display = ‘none’;
crmForm.all.tab2Tab.style.display = ‘none’;
crmForm.all.tab3Tab.style.display = ‘inline’;
crmForm.all.tab4Tab.style.display = ‘none’;
crmForm.all.tab5Tab.style.display = ‘none’;
crmForm.all.tab6Tab.style.display = ‘inline’;
crmForm.all.tab7Tab.style.display = ‘none’
}

For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Microsoft CRM 4.0 in Firefox August 15, 2009

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , ,
add a comment

d4 logo

crm ampersand firefox2

For those Microsoft CRM users that prefer using Firefox as your browser, this post is for you. First you need to install the IE tab add- on https://addons.mozilla.org/en-US/firefox/addon/1419.

firefox addon Once the install is done you will be prompted to restart Firefox. Once restarted go to your CRM site and right click on screen and select “view page in IE tab” and thats it!

For more information about Dynamics Four or to contact us please visit http://dynamics4.com

Showing records when offline in Microsoft CRM 4.0 Outlook Client August 4, 2009

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , ,
add a comment

d4 logo

Ever wonder why when going offline with the Microsoft CRM 4.0 Outlook Client you can only see records that you own? I made a video and and put it on youtube, Hopefully this video will shed some light.

For information about Dynamics Four or to contact us please visit http://dynamics4.com