Ok. Then, you can give the condition like this, if(a.Site!='') in the trigger.
Validation rule: If you want to use validation rule, you can use the below formula for Site field,
IF( Site <> 'www.anna.com',true,false)
This means if the site value is not 'www.anna.com' then it should throw an error. It will only save one value and that is 'www.anna.com'.
You can give an error message and give instructions to the user to choose the site as 'www.anna.com'.
You can not give a value in validation rule as the return type should be boolean. You can just make sure it is entered properly as per the condition given like in the formula.
Workflow rule: And, you can use workflow rule where the rule checks if(a.Site!='') and if so, do a field update which gives the value 'www.anna.com' to the Site field.
Workflow rule:
Field Update:
Do not forget to activate the workflow once everything is set up.
If you just need to change the site to the above value, you can use the below code,
trigger accountSite on Account (before insert) { for(Account a:Trigger.new){ if(a.Site=='www.a.com'){
a.Site='www.anna.com';
} }
}
If there is any calculation on how to get 'www.anna.com' out of 'www.a.com', then we need to change the above code as it just changes the value without any further calculation. Let me know.
any other webiste if i give means it should come as(www.anna.com)...not only for this website(www.a.com)...any website give in field it must be (www.anna.com)..before insert using triggers
Ok. Then, you can give the condition like this, if(a.Site!='') in the trigger.
Validation rule: If you want to use validation rule, you can use the below formula for Site field,
IF( Site <> 'www.anna.com',true,false)
This means if the site value is not 'www.anna.com' then it should throw an error. It will only save one value and that is 'www.anna.com'.
You can give an error message and give instructions to the user to choose the site as 'www.anna.com'.
You can not give a value in validation rule as the return type should be boolean. You can just make sure it is entered properly as per the condition given like in the formula.
Workflow rule: And, you can use workflow rule where the rule checks if(a.Site!='') and if so, do a field update which gives the value 'www.anna.com' to the Site field.
Workflow rule:
Field Update:
Do not forget to activate the workflow once everything is set up.
same requirement above question ..have do in (adderror). in any website if i give means it should come as(www.anna.com)...not only for this website(www.a.com)...any website give in field it must be (www.anna.com)..it should throw an error. before insert using triggers
Ok. Then, you can give the condition like this,
if(a.Site!='') in the trigger.
Validation rule:
If you want to use validation rule, you can use the below formula for Site field,
IF( Site <> 'www.anna.com',true,false)
This means if the site value is not 'www.anna.com' then it should throw an error. It will only save one value and that is 'www.anna.com'.
You can give an error message and give instructions to the user to choose the site as 'www.anna.com'.
You can not give a value in validation rule as the return type should be boolean. You can just make sure it is entered properly as per the condition given like in the formula.
Workflow rule:
And, you can use workflow rule where the rule checks if(a.Site!='') and if so, do a field update which gives the value 'www.anna.com' to the Site field.
Workflow rule:
Field Update:
Do not forget to activate the workflow once everything is set up.
All Answers
If you just need to change the site to the above value, you can use the below code,
trigger accountSite on Account (before insert) {
for(Account a:Trigger.new){
if(a.Site=='www.a.com'){
a.Site='www.anna.com';
}
}
}
If there is any calculation on how to get 'www.anna.com' out of 'www.a.com', then we need to change the above code as it just changes the value without any further calculation. Let me know.
Ok. Then, you can give the condition like this,
if(a.Site!='') in the trigger.
Validation rule:
If you want to use validation rule, you can use the below formula for Site field,
IF( Site <> 'www.anna.com',true,false)
This means if the site value is not 'www.anna.com' then it should throw an error. It will only save one value and that is 'www.anna.com'.
You can give an error message and give instructions to the user to choose the site as 'www.anna.com'.
You can not give a value in validation rule as the return type should be boolean. You can just make sure it is entered properly as per the condition given like in the formula.
Workflow rule:
And, you can use workflow rule where the rule checks if(a.Site!='') and if so, do a field update which gives the value 'www.anna.com' to the Site field.
Workflow rule:
Field Update:
Do not forget to activate the workflow once everything is set up.
before insert using triggers