You need to sign in to do that
Don't have an account?
Rahul Aswale
please can you tell me code apex trigger to show error message when student percentage is above 100or greater than 100
Apex trigger
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hi Rahul,
i hope you can write apex class with appropriate events
i am telling you logic
ORthis code will mark the field with error
this will show error at the bottom of the form
If it solved your query
please mark my answer as best answer :)
All Answers
Hi Rahul,
i hope you can write apex class with appropriate events
i am telling you logic
ORthis code will mark the field with error
this will show error at the bottom of the form
If it solved your query
please mark my answer as best answer :)
This is syntax for displaying the error message using trigger. You can add your condition accordingly.
For more detail, refer this link (https://www.levelupsalesforce.com/salesforce-display-error-message-from-trigger)
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan
for( Student__c std: trigger.new ){
if(std.Number_Of_Percentage__c > 100){
std.addError('Student Percent cannot be more than 100%');
}
}
}
i have write this code but not showing error message when i enter above 100
If it solved your query
please mark my answer as best answer.
Thanks
Priya Ranjan
Here's an example of an Apex trigger that shows an error message when a student's percentage is above 100 or greater than 100:
In this example, the trigger StudentPercentageValidation is executed before a student record is inserted or updated (before insert, before update). It loops through each student record in the trigger's context (Trigger.new) and checks if the Percentage__c field value is greater than 100. If it is, the addError() method is called on the student record, which associates an error message with the record and prevents it from being saved.
Make sure to replace Student__c with the actual API name of your student object and Percentage__c with the API name of your percentage field.
trigger stdpercent Student__c (before insert) {
for( Student__c std : trigger.new ){
if(std.Number_Of_Percentage__c > 100){
std.Number_Of_Percentage__c.addError('Student Percent cannot be more than 100%');
}
}