• Puru Gangwar
  • NEWBIE
  • 30 Points
  • Member since 2014


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hi All ,
I'm getting the Execute Anonymous Error

Line: 1, Column: 18
Constructor not defined: [Employee_Info].<Constructor>(String, Integer
public class Employee_Info {
    

when the following code is run :


    public String name;
        public Integer exp;
        public Decimal salary;
        public Decimal bonus;
        public Employee_Info(String empName,Integer empExp){
            name=empName;
            exp=empExp;
        }
        public void invoke(){
            if(exp > 5){
                salary=50000;
                bonus=5000;
            }else{
                salary=30000;
                bonus=3000;
            }
        }
        public void show(){
            System.debug('Name :'+name);
            System.debug('Exp :'+exp);
            System.debug('Salary:'+salary);
            System.debug('Bonus:'+bonus);
        }
    }

Pls let me know how to fix it .

Thanks
Shilpa
force:recordData is returning parentId on case as null even though valid ParentId exists on the case record.
code:
 
cmp:

<force:recordData aura:id="recordLoader" 
recordId="{!v.recordId}" 
layoutType="FULL" 
fields="Id,ParentId" 
targetFields="{!v.simpleRecord}" 
targetError="{!v.recordError}" 
recordUpdated="{!c.handleRecordUpdated}"
 />


Controller file:
onInit: function (component, event) { 
console.log("oninituccess" + component.get("v.simpleRecord").ParentId); 
}, 
handleRecordUpdated: function (component, event, helper) { 
var eventParams = event.getParams(); 
if (eventParams.changeType === "LOADED") { 
helper.onInit(component, event); 
}
}

 
force:recordData is returning parentId on case as null even though valid ParentId exists on the case record.
code:
 
cmp:

<force:recordData aura:id="recordLoader" 
recordId="{!v.recordId}" 
layoutType="FULL" 
fields="Id,ParentId" 
targetFields="{!v.simpleRecord}" 
targetError="{!v.recordError}" 
recordUpdated="{!c.handleRecordUpdated}"
 />


Controller file:
onInit: function (component, event) { 
console.log("oninituccess" + component.get("v.simpleRecord").ParentId); 
}, 
handleRecordUpdated: function (component, event, helper) { 
var eventParams = event.getParams(); 
if (eventParams.changeType === "LOADED") { 
helper.onInit(component, event); 
}
}

 
Hi All ,
I'm getting the Execute Anonymous Error

Line: 1, Column: 18
Constructor not defined: [Employee_Info].<Constructor>(String, Integer
public class Employee_Info {
    

when the following code is run :


    public String name;
        public Integer exp;
        public Decimal salary;
        public Decimal bonus;
        public Employee_Info(String empName,Integer empExp){
            name=empName;
            exp=empExp;
        }
        public void invoke(){
            if(exp > 5){
                salary=50000;
                bonus=5000;
            }else{
                salary=30000;
                bonus=3000;
            }
        }
        public void show(){
            System.debug('Name :'+name);
            System.debug('Exp :'+exp);
            System.debug('Salary:'+salary);
            System.debug('Bonus:'+bonus);
        }
    }

Pls let me know how to fix it .

Thanks
Shilpa
I created a trigger to update a custom field (Mailing County) before insert of a Contact.  The trigger takes the MailingPostalCode entered by the user and finds the County in which that zip code is found.  This is done via a custom object (Zip_Code__c) in which the Postal Codes are stored along with their respective Counties.

I would love any feedback on how to make this trigger better, but specifically I am confused because one of my test methods is not working (TestContactWithValidZip).  This particular test gets caught by my addError clause of my trigger.

Trigger:
trigger CountyLookupByZip on Contact (before insert) {
    for (Contact c : Trigger.New) {
        if(c.MailingPostalCode != null) {
        	List<Zip_Code__c> contactCounty = new List<Zip_Code__c>();
            contactCounty = [SELECT Id,
                                County__c,
                                Postal_Code__c
         				 FROM   Zip_Code__c 
        			     WHERE  Postal_Code__c = :c.MailingPostalCode];
            if(contactCounty.size() != 0){
            	c.Mailing_County__c = contactCounty[0].County__c;
            } else {
                c.MailingPostalCode.addError('Postal Code not found. Please ensure the postal code is a valid Virginia zip code.');
            }
        }
	}
}
Test Clas:
@isTest
public class TestCountyLookupByZip {

    @isTest
    public static void TestContactWithNullZip() {
        // Test data setup
        // Create a contact without a Mailing Postal Code
        // and check to ensure County is also null
        Contact contactNullZip = new Contact(LastName = 'Test');
        insert contactNullZip;
        
        // Perform Test
        System.assertEquals(contactNullZip.Mailing_County__c, null);
    }

    @isTest
    public static void TestContactWithValidZip() {

        // Test data setup
        // Create a contact with a valid VA Mailing Postal Code
        // and check to ensure County is updated correctly
        
    	Contact contactValidZip = new Contact(LastName = 'Test', MailingPostalCode = '20101');
        insert contactValidZip;
        
        // Perform Test
        System.assertEquals(contactValidZip.Mailing_County__c, 'Loudoun');
    }   
    
    @isTest
    public static void TestContactWithInvalidZip() {
        // Test data setup
        // Create a contact with an invalid Mailing Postal Code
        // and throw an error
        Test.startTest();
        try {
       		Contact contactInvalidZip = new Contact(LastName = 'Test', MailingPostalCode = '17602');
        	insert contactInvalidZip;
        // Perform Test
        } catch(Exception e) {
			System.Assert(e.getMessage().contains('FIELD_CUSTOM_VALIDATION_EXCEPTION'));
            System.Assert(e.getMessage().contains('Postal Code not found. Please ensure the postal code is a valid Virginia zip code.'));
        }
        Test.stopTest();
    }
}