• Salesforce Admin 78
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi

1. I have created a validation rule on custom object.
2. I'm receiving error two times on VF page when validation rule is true and my error location is top of page.
3. I have added <apex:pagemessages /> on VF page.
4. In Apex Controller i have added apexpages.addMessages(e); in catch exception 

My Validation Rule 
AND(TEXT(ZDCP__c) <> null, ISBLANK(PCM_Sheet__r.Agent__c ))

Error is showing like this:
User-added image


Can anybody please tell how can i get the error one time.??

 
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.

Apex class-
global class Deleteoppotest implements Schedulable{

global void execute(SchedulableContext SC) {
    deleteoppo();
}

public static void deleteoppo() {

    for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
        {
            delete objoppo;
        }    
}

Test Class-
@isTest
private class Deleteoppotestcls {

static testMethod void myUnitTest() {
    // TO DO: implement unit test



    Opportunity op = new Opportunity();
    op.Name = 'test1';
    op.StageName = 'Qualified';
    op.CloseDate = Date.Today();
    op.Description ='testingoppotestcls';
    op.Business_Type__c = 'Domestic';


    insert op;


    Deleteoppotest.deleteoppo();

}
}

 
Hi

1. I have created a validation rule on custom object.
2. I'm receiving error two times on VF page when validation rule is true and my error location is top of page.
3. I have added <apex:pagemessages /> on VF page.
4. In Apex Controller i have added apexpages.addMessages(e); in catch exception 

My Validation Rule 
AND(TEXT(ZDCP__c) <> null, ISBLANK(PCM_Sheet__r.Agent__c ))

Error is showing like this:
User-added image


Can anybody please tell how can i get the error one time.??

 
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.

Apex class-
global class Deleteoppotest implements Schedulable{

global void execute(SchedulableContext SC) {
    deleteoppo();
}

public static void deleteoppo() {

    for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
        {
            delete objoppo;
        }    
}

Test Class-
@isTest
private class Deleteoppotestcls {

static testMethod void myUnitTest() {
    // TO DO: implement unit test



    Opportunity op = new Opportunity();
    op.Name = 'test1';
    op.StageName = 'Qualified';
    op.CloseDate = Date.Today();
    op.Description ='testingoppotestcls';
    op.Business_Type__c = 'Domestic';


    insert op;


    Deleteoppotest.deleteoppo();

}
}