You need to sign in to do that
Don't have an account?
anvesh@force.com
User Field value is not assigned ?
I have created a trigger.. contact is lookup. and i am assigning contact obj user value to current object.debug logs showing the value existed. but it is not assigned in record field.?
trigger NIGO_update on NIGOs__c(before insert,before update){
List<NIGOs__c> NgList = [select id,name,Contact_Name__c,Product_Type__c,Contact_Name__r.Annuity_Territory_Wholesaler__r.id,Contact_Name__r.Annuity_Territory_Wholesaler__c,Contact_Name__r.Forecare_Territory_Wholesaler__r.id from NIGOs__c where id in:Trigger.new];
for(NIGOs__c ng:NgList){
if(ng.Product_Type__c != 'Forecare'){
if(ng.Contact_Name__c != Null){
ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id;
}
}
System.debug('Ext1'+ng.External_Wholesaler__c);
}
}
trigger NIGO_update on NIGOs__c(before insert,before update){
List<NIGOs__c> NgList = [select id,name,Contact_Name__c,Product_Type__c,Contact_Name__r.Annuity_Territory_Wholesaler__r.id,Contact_Name__r.Annuity_Territory_Wholesaler__c,Contact_Name__r.Forecare_Territory_Wholesaler__r.id from NIGOs__c where id in:Trigger.new];
for(NIGOs__c ng:NgList){
if(ng.Product_Type__c != 'Forecare'){
if(ng.Contact_Name__c != Null){
ng.External_Wholesaler__c = ng.Contact_Name__r.Annuity_Territory_Wholesaler__r.id;
}
}
System.debug('Ext1'+ng.External_Wholesaler__c);
}
}
There's another issue here though - when you are inserting records, they won't have an id so the query won't return any values for the before insert case.
For updates, you can retrieve the related records, but you need to update the associated record from the trigger. You can get this by retrieving from trigger.newMap based on the record id.