0

I need to populate a currency custom field Value_Of_WE_Spend__c on a custom object WE_FEP__c with the value from an opportunity currency custom field Annual_Settlement_Value__c.

I've written the below code, which works without the recToCreate.Value_Of_WE_Spend__c... section but when the button's clicked with this section included, the following error message is displayed:

{"faultcode:'soapenv:Client', faultstring "GBP 10,000.00' is not valid for the type xsd:double',}

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

try{ 
    var recToCreate = new sforce.SObject("WE_FEP__c");  
    recToCreate.Account_Name__c = '{!Opportunity.AccountId}';
    recToCreate.Name = '{!Opportunity.Name}';   
    recToCreate.Description__c = '{!Opportunity.Description}';
    recToCreate.Value_Of_WE_Spend__c = '{!Opportunity.Annual_Settlement_Value__c}';

    var result = sforce.connection.create([recToCreate]); 

    if(result[0].success == "true"){
    window.location = "/" + result[0].id + "/e";
    }
    else{
        alert("An Error has Occurred. Error:" + result[0].errors.message);
    }
}
catch(e){
    alert("An Error has Occurred. Error:" + e);
}
  • 1
    try setting it as recToCreate.Value_Of_WE_Spend__c = '{!TEXT(Opportunity.Annual_Settlement_Value__c)}' – Rajiv Bhatt Apr 23 '15 at 9:54
  • Thanks, that worked, if you'd like to post that answer then I'll select it. – Alex S Apr 23 '15 at 9:56
1

You need to use the text function to convert the currency field in the actual value. This should fix the issue:

recToCreate.Value_Of_WE_Spend__c = '{!TEXT(Opportunity.Annual_Settlement_Value__c)}';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.