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

Apex Class to only execute when Record developername = 'intermittent'
Afternoon Team,
I think i am having one of these days where i cant do the basics in salesforce.
Aim : I would like the class below to only execute if the recordtype developername = "intermittent'". If the recordtype developername = "pending' then do nothing. Currently my class below executes on either Record type. "intermittent" or "pending ".
This is the query i use to Query RT Object for Flow object
select id,developername,Name from RecordType where SobjectType='flow__c' and developername='intermittent'
I have created a trigger which calls an utils class
Trigger:
/******************************************************************** * UpdateCurrencyInsert * * Before Insert trigger on Flow ********************************************************************/ trigger UpdateCurrencyInsert on Flow__c (before insert) { FlowUtils.ValidateCurrencyUpdate(Trigger.new); }
Class:
public class FlowUtils { public static void ValidateCurrencyUpdate(List<Flow__c> flows ) { List<Id> opportunityIds = new List<Id>(); Map<Id, String> oppIdCurrencyCode = new Map<Id, String>(); for (Flow__c Flow: flows ) { opportunityIds.add(Flow.opportunity__c); } for(Opportunity opp : [Select CurrencyIsoCode from Opportunity where Id in: opportunityIds]) { oppIdCurrencyCode.put(opp.Id, opp.CurrencyIsoCode); } for(Flow__c flow : flows) { flow.CurrencyIsoCode = oppIdCurrencyCode.get(flow.opportunity__c); } } }Looking forward to your help and advise
Let us know if this will help you
All Answers
Use below code. It would be helpful for you.
You have to be two changes in your code.
1.) Please write record type id of intermittent record type which I have mentioned below.
2.) Use opportunity CurrencyIsoCode field for update value in flow object field.
3.) Use set instead of List. because the set is used for giving a unique value.
Implement it, if you have any query please let me know.
Thanks,
Arvind Kumar
Let us know if this will help you
@Amit - Thanks for providing that solution. that is exactly what i wanted :)