You need to sign in to do that
Don't have an account?
Trigger on Opportunity with custom object
i have a custom object, mfg cost, that has 80 records... each record has a process, min qty, max qty and cost.... to calculate the mfg cost, several records must be retrieved for the various processes required.... this mfg cost is a custom field on the opportunity that i want to populate with trigger prior to insert or update...
i don't understand lists, sets, etc very well, and am concerned that if i do a select for each process type, i will run into govern limits....
a couple of example records in custom object:
PROCESS MIN QTY MAX QTY COST
LO 1 499 3.50
LO 500 999 3.00
TN 1 499 1.50
TN 500 750 1.30
etc..... in one example, i may need to get the cost from record 1 and 3, and in another, 2 and 4.... anyways, currently, i am doing 2 different selects rather than doing a list or set (again, i don't really understand how to utilize them)...
any suggestions would be greatly appreciated....thanks much in advance.
Have you thought about making this data into a Custom Setting (List)?
https://login.salesforce.com/help/doc/en/cs_about.htm
You can easily access this data via the methods for Custom Settings, and you will have to worry much less about limits.
You probably want to use a MAP e.g. map(string, CustomObject__c) and add the lookup values as the string and the sObject as the record. and when you need to call a value, just call the map.get('Lo') etc. Hope this makes sense.
I can explain further but this may be enough for you to understand...http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_map.htm
Good luck.
Mike
Thank you both for your responses.... i'm using maps... and creating a map for each process type... below is an example...
don't know if this is the best way, but it seems to be working... thanks again for your help...
Map<ID,Mfg_Run_Charges__c> mrcLO = new Map<ID,Mfg_Run_Charges__c>([
SELECT ID, Min_Qty__c,Max_Qty__c,Per_M_Charge__c, Setup_Charge__c, PunchOnly_per_M__c
FROM Mfg_Run_Charges__c
WHERE Process_Code__c = 'LO']);
Map<ID,Mfg_Run_Charges__c> mrcPS = new Map<ID,Mfg_Run_Charges__c>([
SELECT ID, Process_Code__c, Min_Qty__c,Max_Qty__c,Per_M_Charge__c, Setup_Charge__c
FROM Mfg_Run_Charges__c
WHERE Process_Code__c = 'PS']);
etc............
and then will access appropriate LO record from map based on quantity... if this seems totally ludicrous, please let me know....