1
votes

We have a Dynamics CRM 4.0 instance with some custom attributes of type "money" on the Case entity and on all Activity entities (Email, Phone Call, etc.) When I use the built-in "Convert Activity to Case" functionality I find that the resulting Case does not have a Currency set, even if the Activity it was created from does have it. Whenever the case is opened the user then gets this JavaScript error:

A currency is required if a value exists in a money field. Select a currency and try again.

This is extremely annoying! How do I fix it? Is there any way I can set the currency? It needs to be done synchronously, because the Case is opened immediately when it's created from an Activity. So even if I started a workflow to set the currency the user would still get that error at least once. Alterntatively, can I just suppress the warning somehow? I don't really care about setting the Currency, I just want the error gone.

8

8 Answers

3
votes

I guess this code will be helpful for next person who have a same problem. I spent whole day to figure out what I did below.

There are two steps involved here:

  1. set default currency
  2. set currency symbol for the money field.

Here is the code sample.

var currency = crmForm.all.transactioncurrencyid;

if (currency.DataValue == null) {
    var lookupData = new Array();
    var lookupItem= new Object();

    //Get transaction currency value from :
    select **TransactionCurrencyId** from MSCRM.dbo.TransactionCurrency
        lookupItem.id = '{The GUID that you get from the SELECT statement above}';
        lookupItem.typename = 'transactioncurrency';
        lookupItem.name = 'US Dollar';
        lookupData[0] = lookupItem;
        currency.DataValue = lookupData;
    //set default currency symbol for all the Money field.
    var defaultSymbol = '$';
    for(var i=0; i < crmForm.all.length ; i++)   {
        var oCtr = crmForm.all[i];
        if(!IsNull(oCtr.IsMoney) && !oCtr.IsBaseCurrency)
        {
            oCtr.CurrencySymbol = defaultSymbol;
        }
    }
}
2
votes

This annoying issue was resolved on my system by discovering the transactioncurrencyid used for US dollars and then updating the transactioncurrencyid column in the entity's database table for all the existing entity records. After doing this I was able to add money values on the entity form with no further problems. Not sure if this solution would be ideal for everyone, but as I did not want to write code to do this and felt I shouldn't have to since if I added money attributes to a newly defined entity it didn't require writing code on my part to populate the transactioncurrencyid field - it just did it by default. So in summary, this problem only seems to occur if the the money fields are added to an existing entity that has existing data associated with it.

2
votes

set default currency in Personalize Workspace, General tab NEW records will use this currency For EXISTING records (before money field(s) added) use Advanced Find to find records with NO currency value, then use Bulk Edit to set currency

1
votes

You might want to check out this article CRM 4 Currency Calculations by Mitch Milam

Update : After googling around, i found out that you might need to set the transactioncurrencyid lookup somewhere. So in your case, it might be onsave or inside the execution of the workflow codes. I read it from here Error: Assign a decimal value to CRM 4.0 money field using Javascript

1
votes

If your form has a money field on it, CRM needs to know which currency to use. Verify that a default currency is set in your user preferences (Personalize Workplace from the main page, then the General tab). That is, each of your users will need to have a default currency set.

I have also been able to work around this issue by adding the currency field to the form, defaulting it to US dollars, and then hiding the field. If memory serves, though, this isn't ideal because the US dollars currency is a record in the system and can have different GUIDs in different environments.

1
votes

Since this thread came up in my Google search when I was looking for a solution to this problem for CRM 2011, I thought I'd add my blog article explaining how to set the default currency lookup in the Onload of a CRM 2011 form using JavaScript, JSON and OData.

http://crmscape.blogspot.com/2011/03/crm-2011-set-default-transaction.html

0
votes

I agree with Hadi Teo that you need to set the transactioncurrencyid. Its been awhile since I ran across this - so here is what I think I remember.

If you create a new entity with a money field populated the transaction currency will be set. If you update an entity, the transaction currency field will not be set.

I haven't used the Activity to Case function so I'm not all that sure what it does. One thing you can do as a work around is to add the transactioncurrencyid onto the form. Then you can set it before you modify your Case.

The other would be to default the currency in code. There are two places to determine the default currency. First off of the user settings. Second (if that is null) off of the organization settings.

0
votes

Fix for this problem 1. Add the base currency field also to the form. 2. Untick the "visible by default option" of the base currency field.