function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinay SalveVinay Salve 

Quick Start - Apex Coding for Admins

Hello Team,

While doing the trailhead for Quick Start - Apex Coding for Admins - Create a Trigger, while I am creating the candidate Nina Simone, and update the ZIP Code field as "20008", system gives me an error message stating as - Candidate Zip Code does not exist in specified State.

Kindly advise where I am going incorrect.

Thanks
Vinay Kumar Salve
Best Answer chosen by Vinay Salve
Abdul KhatriAbdul Khatri
It seems like you have triggers from other trailheads that are active, most probably you are working off the same playground for multiple trailheads which is basically overlapping over the functional implementation and making this simple trailhead difficult to pass. Can you please disable all Contact triggers as I don't think you need any for this trailhead.

All Answers

Raj VakatiRaj Vakati
Looks like you dnt have any values in the Zip_Code__c  object .. create a  new record record in the Zip_Code__c  for 20008 and try 
Vinay SalveVinay Salve
Thanks Raj, however I am not able to create a record as ZIP/Postal Code is a Standard Object and not a Custom Object, please assist, thanks
Abdul KhatriAbdul Khatri
Hi Vinay,

Can you please verify how many triggers, workflow, validation Rule, process builder etc. for Candiate Object you have. I dont' think the error you are getting is part of any implementation you have done for this Trailhead.

Can you please also check in Org for the text Candidate Zip Code does not exist in specified State.
Vinay SalveVinay Salve
Hello All,

Request you to please assist, as I am still stuck with same error - Candidate Zip Code does not exist in specified State

Thanks
Vinay Kumar Salve
Abdul KhatriAbdul Khatri
Please share your code.

Can you also make sure all the triggers related to the object are deactivated, in case if there are?
Vinay SalveVinay Salve
Hi Abdul

Please find the trigger on candidate object

trigger CreateContact on Candidate__c (after insert){
    //Instantiate an object called cc from the class CreateContactFromCan
    CreateContactFromCan cc = new CreateContactFromCan();
    //Invoke the method createContact and send a List of Candidates as an input parameter
    cc.createContact(Trigger.new);
}

validation rule

VLOOKUP($ObjectType.Zip_Code__c.Fields.State__c, $ObjectType.Zip_Code__c.Fields.Name, LEFT( Zip_Postal_Code__c ,5) ) <> State_Province__c

Please assist, what am I doing incorrect

Thanks
Vinay Kumar Salve
Abdul KhatriAbdul Khatri
What is this validation rule is for? I don't think it is part of the trailhead module? Can you make it inactive?

User-added image
Vinay SalveVinay Salve
Hi Abdul,

I have tried with deactivating the validation rule, now I receive the following error, please assist, thanks

Couldn’t find the record named 'Nina Simone' with Email 'nsimone@test.com'. Please double check the instructions.

Thanks
Vinay Kumar Salve
Abdul KhatriAbdul Khatri
Man you are just creating this new record. Seems like you have something like trigger, workflow etc. that is basically is resulting this issue.

Do you have any trigger for Contact Object? Can you deactivate any trigger related to Contact SObject? Please share the screenshot of triggers list?
Vinay SalveVinay Salve
Hi Abdul,

I had the following trigger on contact standard object which I have now removed

1. Example Trigger on contact
trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
        EmailManager.sendMail('vinaykumarsalve@gmail.com', 'Trailhead Trigger Tutorial', 
                    recordCount + ' contact(s) were inserted.');
    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}


2. RestrictContactByName

trigger RestrictContactByName on Contact (before insert, before update) {
  
  //check contacts prior to insert or update for invalid data
  For (Contact c : Trigger.New) {
    if(c.LastName == 'INVALIDNAME') {  //invalidname is invalid
      c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
    }
  }
Vinay SalveVinay Salve
Hi Abdul,

Even after removing the above mentioned trigger from contact, I still get the following error

CreateContact: execution of AfterInsert caused by: System.QueryException: List has more than 1 row for assignment to SObject Class.CreateContactFromCan.createContact: line 5, column 1 Trigger.CreateContact: line 5, column 1

Please assist, thanks
Vinay Kumar Salve
Abdul KhatriAbdul Khatri
It seems like you have triggers from other trailheads that are active, most probably you are working off the same playground for multiple trailheads which is basically overlapping over the functional implementation and making this simple trailhead difficult to pass. Can you please disable all Contact triggers as I don't think you need any for this trailhead.
This was selected as the best answer
Vinay SalveVinay Salve
Thanks for your support Abdul, I tried it in new Trailhead Playground and it worked fine.
teja naiduteja naidu
CreateContact: execution of AfterInsert caused by: System.QueryException: List has more than 1 row for assignment to SObject Class.CreateContactFromCan.createContact: line 5, column 1 Trigger.CreateContact: line 5, column 1

Even im Facing the same problem can anyone please help me?
Abdul KhatriAbdul Khatri
Please share the code for providing the solution.

Seems like your SOQL is returning multiple results for the filtere which is causing issue while you were doing any assignments based on that.