Question : CRM 4.0: issues pre-populating a Currency lookup and money field ("A currency is required if a value exists in a money field")

I am trying to populate a form with data based on a selection in a Lookup.  For this, I am using the onChange event of the Lookup.  One of the form fields is a money field and an error was thrown when I tried to populate it.

"A currency is required if a value exists in a money field"

To get around this, I added a currency field to the entity and form.  In testing, I selected a currency manually on the form, then changed the Lookup value which triggered the onChange and the money field was populated with no errors.  Great!

However, I would like to pre-populate the currency too.  This is where I run into problems.  I have dealt with Lookups before and I know that you have to set the id, name and typename.  This works just fine for me so far.  I have used the same code several times to do this (see below)

However, when I do the same thing with the Currency Lookup, I get the same dialog box as before:

"A currency is required if a value exists in a money field"

The currency is set (by me) yet the system doesn't acknowledge it at the time when it validates the money field.  I can SEE that the currency field is populated with my own eyes!  It's on the form, just behind the error message alert.

I ran debugging in two scenarios:

1) inspect the data structure and values of crmForm.all.transactioncurrencyid.DataValue after being selected from a Lookup
2) inspect the data structure and values of crmForm.all.transactioncurrencyid.DataValue after being populated by me

They are identical.

I added the ForceSubmit to the end because I thought that maybe the form didn't have the currency value when the money value was being populated, but no, this behaviour still exists.

Is there an extra special thing that needs to be set for Currency Lookups?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
// getLookupID returns the GUID of the Lookup field passed to it, returns null if isn't populated
	var sCurrencyID = getLookupID(crmForm.all.transactioncurrencyid.DataValue);
	if (sCurrencyID == null)
	{
		var currencyObject = new Object;
		var currencyObjectArray = new Array();
		currencyObject.id = ;
		currencyObject.name = ;
		currencyObject.typename = "transactioncurrency";
		currencyObjectArray[0] = currencyObject;
		crmForm.all.transactioncurrencyid.DataValue = currencyObjectArray;
		crmForm.all.transactioncurrencyid.ForceSubmit = true;
	}

Answer : CRM 4.0: issues pre-populating a Currency lookup and money field ("A currency is required if a value exists in a money field")

It looks like it was a config issue.  All working now
Random Solutions  
 
programming4us programming4us