You need to sign in to do that
Don't have an account?
sagar patil 13
Set Standard field 'Name' value automatically by code or formula field or workflow
Requirement:
Custom Object Name=CaseConfig__c
Fields of CaseConfig__c
1.Product(lookup)
2.SRType(lookup)
Name of CaseConfig__c should be automatically set by concatenating Names of product & SRType Object.
User will fill values of product & SrType only. value of Name Field of CaseConfig__c should be generated automatically.on insert or update
Custom Object Name=CaseConfig__c
Fields of CaseConfig__c
1.Product(lookup)
2.SRType(lookup)
Name of CaseConfig__c should be automatically set by concatenating Names of product & SRType Object.
User will fill values of product & SrType only. value of Name Field of CaseConfig__c should be generated automatically.on insert or update
I have written a Trigger, Check it. Let me know if anything wrong
trigger CaseConfiguration on CaseConfig__c (before insert,before update) {
Set<Id> ProductId = new Set<Id>();
Map<Id, String> ProductMap = new Map<Id, String>();
Set<Id> SRTypeId = new Set<Id>();
Map<Id, String> SRTypeMap = new Map<Id, String>();
for(CaseConfig__c cas : Trigger.New){
ProductId.add(cas.Product__c);
}
for(CaseConfig__c cas1 : Trigger.New){
SRTypeId.add(cas1 .SRType__c);
}
for(Product__c pro : [Select Name from Product__c where Id IN : ProductId]){
ProductMap.put(pro.Id, pro.Name);
}
for(SRType__c sr : [Select Name from SRType__c where Id IN : SRTypeId ]){
SRTypeMap.put(sr.Id, sr.Name);
}
for(CaseConfig__c cascon : Trigger.New){
cascon.Name = ProductMap.get(cascon.Product__c) +' '+ SRTypeMap .get(cascon.SRType__c);
}
}
Thanks & Regards
SAGA BJ