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

Null value when retrieving values in trigger
For(contract__c con:trigger.new){
con.Owner__c = con.Opportunity__r.Account.createdBy.ID;
con.Region__c= con.Opportunity__r.Account.Region__c;
}
con.Opportunity__r.Account.createdBy.ID,con.Opportunity__r.Account.Region__c these values are NULL , How to pass values into Contract when they are related other opportunity and opportunity related to contract.
But i want to bulkify my code!!!!!!
For(contract__c con:trigger.new){
for(Opportunity o:oppall){
if(Con.Opportunity__c == o.ID ){
acc = [Select Id,createdBy.ID,Country_Code__c,ClientID__c,Region__c,Station__c,Country__c From account where Id =:o.AccountId];
con.Owner__c = acc.createdBy.ID;
con.Region__c=acc.Region__c;
con.Country_Code__c=acc.Country_Code__c;
con.Station__c=acc.Station__c;
con.Country__c=acc.Country__c;
}
}
set<id> OppIDset = new set<Id>();
For(contract__c con:trigger.new)
{
OppIDset .add(con.Opportunity__c);
}
Select id,name,Account.Id,Account.createdBy.ID,Account.Country_Code__c,Account.ClientID__c,Account.Region__c,Account.Station__c,Account.Country__c From Opportunity where Id in: OppIDset