You need to sign in to do that
Don't have an account?
Rupesh A 8
How to write validation rule for making field is required
Hi,
Scenario is, In Account object I have "Legal Entity" field, as we all know that there must be a relationship between Oppurtunity and Account objects.
So in Oppurtunity I have created one formula field like "Account Legal Entity" (formula is TEXT(Account.Legal_Entity__c)). Here I need to make this field as mandatory by using Validation rule. can anyone help me on this?
Thanks.
Scenario is, In Account object I have "Legal Entity" field, as we all know that there must be a relationship between Oppurtunity and Account objects.
So in Oppurtunity I have created one formula field like "Account Legal Entity" (formula is TEXT(Account.Legal_Entity__c)). Here I need to make this field as mandatory by using Validation rule. can anyone help me on this?
Thanks.
Thanks
Actually I should not keep input field as required like that as per my requirement. ok let's try another one, if we dont have any formula field like Account Legal entity. As usual there must be a relationship b/w Account and Oppurtunity right if I create oppurtunity record then in any Account record is having the Legal Entity then the Oppurtunity record should create otherwise it should throw the error.
How can we acheive this? Thanks.
for this you have to write trigger create a field in opportunity "Account Legal Entity" in below trigger i am expecting api name as "Account_Legal_Entity__c " i am writting logic in trigger you can move it to class also .
Trigger Account_Legal_Entity on Opportunity(before insert){
set<id> accid=new set<id>();
if(Trigger.isbefore&&Trigger>isInsert){
for(Opportunity op:Trigger.new){
accid.add(op.accountid);
}
Map<id,Account> maaccount=new Map<id,Account>([select id,Account_Legal_Entity__c from Account where id IN:accid]);
for(opportunity op:Trigger.new){
Account ac=maaccount.get(op.accountid);
if(ac.Account_Legal_Entity__c!=null){
op.Account_Legal_Entity__c=ac.Account_Legal_Entity__c ;
}
else{
op.addError('Opportunity's Account don't have Account_Legal_Entity__c ');
}
}
}
}
If its helps ples like this :)