You need to sign in to do that
Don't have an account?
help in Trigger testmethod
trigger Trigger_ValidateGrandTotal on Account (before update) {
public decimal GrandtotalLimit=0;
Admin__c adminvar = [select Grand_Total_Limit__c from Admin__c where Name='CallPlan' and ownerId= :UserInfo.getUserId() ];
GrandtotalLimit=adminvar.Grand_Total_Limit__c;
for( Account acc:trigger.new)
{
if(acc.Grand_Total__c > GrandtotalLimit)
{
acc.addError('You have exceeded the limit of '+GrandtotalLimit+' for Account '+acc.name+'. Please review and modify the allocation');
break;
}
}
HI
This is the code, You can refer, You need to change your trigger little bit.
If this post answers your questions, please mark it as solved and give kudos if this helps you
Thanks
thanks for the reply.
But I am getting an error that
"
Error: Compile Error: Field is not writeable: Account.AxtriaCallPlan__Grand_Total__c at line 9 column 89
that is in this line--
how to make it pass..
"
HI
Formula fields are always readonly , so we will never add some value to that field.
So change this line
Account act = new Account(name = 'testaccount',Grand_Total__c = 7.00);
to
Account act = new Account(name = 'testaccount');
insert act;
If this post answers your questions, please mark it as solved and give kudos if this helps you
Thanks
Don't use Grand_Total__c while creating account as its a formula field it will automatically gets populated..Just put name and other mandatory fields to create an account. in testclass.
Reagrds,
Itsaws
thanks for the reply.
I removed Grand_total field and try to run the testclass .
the testclass has failed and I couldnt get the required code coverage.
Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [AxtriaCallPlan__Account__c]: [AxtriaCallPlan__Account__c] Stack Trace Class.AxtriaCallPlan.AccountTriggerTestClass.validateHelloWorld: line 10, column 1
What is the thing that I am missing.
check which object contains [AxtriaCallPlan__Account__c field and about field type ,now assign some value to that field
then run the test.