You need to sign in to do that
Don't have an account?

Set Currency Picklist value
Hi there, we have a custom object "Invoice Request" that has a lookup relationship with Opportunity. I want the standard currency picklist field on the Inoice Request record set to whatever value is in the standard currency picklist field on the Opportunity record. This should only happen on creation of the Invoice Request record, users should be able to invoice in whatever currency they choose.
Thanks in advance
Paul
Hi Paul,
I would have written a pretty simple trigger as below:
I am assuming relation name is Opportunity__c in Invoice_request__c object, you can modify this name as you might have used:
trigger UpdateCurrency on Invoice_Request__c (before insert) {
List<Id> opportunityIds = new List<Id>();
Map<Id, String> oppIdCurrencyCode = new Map<Id, String>();
for(Invoice_Request__c ir : System.Trigger.new) {
opportunityIds.add(ir.opportunity__c);
}
for(Opportunity opp : [Select CurrencyIsoCode from Opportunity where Id in: opportunityIds]) {
oppIdCurrencyCode.put(opp.Id, opp.CurrencyIsoCode);
}
for(Invoice_Request__c ir : System.Trigger.new) {
ir.CurrencyIsoCode = oppIdCurrencyCode.get(ir.opportunity__c);
}
}
Please post if you found any better approach or have any questions.
-Vagish
All Answers
It is on the layout but when you create a new Invoice Request the CurrencyISOCode defaults to the users currency and not the opportunity currency, I also cannot do a workflow field update either hence the need to use a trigger ( I think)
Thanks
Paul
/001/e?currencyIsocode=USD&no.override=1
Thanks for that, doesn't sound that simple to me ;-) but i'll take your word for it
http://www.salesforce.com/docs/developer/cookbook/Content/vf_conditional_page.htm
Hi Paul,
I would have written a pretty simple trigger as below:
I am assuming relation name is Opportunity__c in Invoice_request__c object, you can modify this name as you might have used:
trigger UpdateCurrency on Invoice_Request__c (before insert) {
List<Id> opportunityIds = new List<Id>();
Map<Id, String> oppIdCurrencyCode = new Map<Id, String>();
for(Invoice_Request__c ir : System.Trigger.new) {
opportunityIds.add(ir.opportunity__c);
}
for(Opportunity opp : [Select CurrencyIsoCode from Opportunity where Id in: opportunityIds]) {
oppIdCurrencyCode.put(opp.Id, opp.CurrencyIsoCode);
}
for(Invoice_Request__c ir : System.Trigger.new) {
ir.CurrencyIsoCode = oppIdCurrencyCode.get(ir.opportunity__c);
}
}
Please post if you found any better approach or have any questions.
-Vagish
i think u can use workflow for this also ..
in this u have to use if and include in formula value ..
try this it is easy
Thanks for that it works well. The only question I would ask is it is possible to update the currency field on creation of the invoice record. It changes on save but this may cause some user confusion.
Many Thanks
Glad to know that it solved your purpose.
The way you are asking is only possible with the approach as Tech Force posted above. You will have to override the new button of list view and then do the url hack.
No worries, will just move the field to be less prominent and advise the users. Thanks again