+ Start a Discussion

trigger help



I have an application custom object and recommender custom object, I have an look up relationship from the application to the recommender.I have an pick list field status in both of these objects, and the values are received and not received.Once , I have the status pick list field  as received in the recommender custom object, I need even the status pick list field in the application field to automatically change to received.Can anyone give me an idea on writing a trigger to kick start with this....I would appreciate any help...


thank you






These what I can suggest:

- Trigger on recommender shall be fired from after update event.

- check whether recommender status has been changed to received. if yest put it in a map by id as key.

- select all applications by  recommender lookup id IN map.keySet()

- loop through the result

- change application's status as desire.

- update list application.


Is it help?




Here is somethign that moves from one object to another, should be helpful, does the same thing.



trigger UpdateToAccSetupForm on Account (before insert, before update) {
	Map<String, String> SetupFormMap = new Map<String, String>();
	for (Account acc : System.Trigger.new){
			SetupFormMap.put(acc.ID, acc.IF_SAP__c);
			if( trigger.old[0].IF_SAP__c != acc.IF_SAP__c) {	
				SetupFormMap.put(acc.ID, acc.IF_SAP__c);
		List<AccountSetupForm__c> recordsforupdates = new list<AccountSetupForm__c>();
	for (AccountSetupForm__c aacc :[Select Id, AccountName__c, SAP_Number__c from AccountSetupForm__c where
		AccountName__c IN : SetupFormMap.keySet()] ){

		if (SetupFormMap.containsKey(aacc.AccountName__c)){
			aacc.SAP_Number__c = SetupFormMap.get(aacc.AccountName__c);
	update recordsforupdates;