function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dkndkn 

trigger help

Hi

 

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

 

 

iBr0theriBr0ther

Hi, 

 

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?

 

Cheers,

MattyDHLMattyDHL

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){
		if(Trigger.isInsert){
			SetupFormMap.put(acc.ID, acc.IF_SAP__c);
		
		}
		else{
			if( trigger.old[0].IF_SAP__c != acc.IF_SAP__c) {	
				SetupFormMap.put(acc.ID, acc.IF_SAP__c);
			}
			else{
			
			}
	}
	}
	
		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);
			recordsforupdates.add(aacc);
		}				
	}
	update recordsforupdates;
}