• Donna Whitig 34
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 13
    Replies
I'm working on the prework for the Lightning Experience Rollout Specialist badge.  I created a new playground and installed the unmanged package.  I'm now stuck on these two steps:
  1. From Setup in either Salesforce Classic or Lightning Experience: Create a user named John Wiseman and assign him to the Salesforce user license and the Custom: Sales Profile profile.
  2. Create a second user named Paloma Espinoza and assign her to the Salesforce Platform user license and the Standard Platform User profile.
I have not "Salesforce" user license and if I choose "Salesforce Platform" license it tells me there are No Salesforce CRM Content User Licenses Available. 
User-added image

Any thoughts?
I need to update contacts that are chosen on lookup fields on an account to have the same values on custom fields as associated account. 
Background:
  • I have two fields on the Account object that lookup directly to the contact object to house Primary Contact 1 and Primary Contact 2.
  • The Account object has two custom fields Main_Page_Access__c and Sub_Page Access__c.  The Contact object has these same custom fields.
  • I want to run a nightly routine that will update the Main_Page_Access__c, Sub_Page Access__c fields on the Contact object with the values from the Account object.  I need help with the Apex class to do the updates.  
I was able to query the Account and get the Primary Contact 1's ID along with the Account ID and the access fields from the Account and add this to a list.  I then did a second query for the Primary Contact 2 and added that to the list.  Now I want to loop through that list and use the Account Main_Page_Access__c, Sub_Page_Access__c field information to update the contacts Main_Page_Access__c, Sub_Page_Access__c fields.  This is where I am stuck.  Keep in mind that I am new to Apex development...  :-)


***********  Here's my code so far ******************

public with sharing class Assign_Access {

    public static void SelectContactsAndAccess() {

        //Find the Account that have Primary Contacts Associated with them

    //Create a list to hold all primary contacts and access information

        List<Account> AllContacts = new List<Account>();
        AllContacts.clear();

    //Fetch first primary contact and add to PrimaryContact1 list where Primary_Contact1__c holds the Contact ID

        List<Account> PrimaryContact1 = [SELECT Id, Name, Primary_Contact1__c, 
                                             Main_Page_Access__c, Sub_Page_Access__c
                                         FROM Account 
                                         WHERE Primary_Contact__c != NULL ];      

        System.debug('PrimaryContact1 ' + PrimaryContact1);

    //Add Primary Contact 1 to AllContacts list

        AllContacts.addall(PrimaryContact1);

    //Fetch second primary contact and add to PrimaryContact2 list where Primary_Contact2__c holds the Contact ID 

        List<Account> PrimaryContact2 = [SELECT Id, Name, Primary_Contact2__c, 
                                Main_Page_Access__c, Sub_Page_Access__c
                                FROM Account 
                                WHERE Primary_Contact2__c != NULL ]; 

        System.debug('PrimaryContact2 ' + PrimaryContact2);

    //Add Primary Contact 2 to AllContacts list

        AllContacts.addall(PrimaryContact2);

        system.debug('AllContacts '+ AllContacts);

}
}
I'm new to coding and trying to write a test trigger in my dev org.  The trigger needs to fire before insert and compare the name of the course being inserted inot my custom object against the existing courses.  If there is a duplicate course being inserted, throw an error.  Here is what I have so far that is not working.  It gives an error that the comparison if statement of "Variable does not exist: Course_Name__c".  Can someone point me in a direction?

=======TRIGGER CODE+++++

trigger testtr1 on Course__c (before insert) {

Public static void CheckDuplicates(List<Course__c> newCourse){             

      //Create a LIST of all existing courses
    List<Coures__c> ExistingCourses= [SELECT Id, Course_Name__c
                            FROM Course__c];

    
    // Create a SET of all incoming  course names to evaluate
  Set<String> Courses = new Set<String>();
    for (Courses__c s : Trigger.new) {
      Courses.add(s.Course_Name__c);
    } /*end for loop */
    
    //Compare SET values to LIST

      for(Courses__c s : Trigger.new)
            if(
                ExistingCourses.Course_Name__c = s.Course_Name__c)
                s.addError('DUPLICATE COURSE NAME');
  

}  /* end ChecDuplicates method */
}   /*end triggger begin */

 
I'm working on the prework for the Lightning Experience Rollout Specialist badge.  I created a new playground and installed the unmanged package.  I'm now stuck on these two steps:
  1. From Setup in either Salesforce Classic or Lightning Experience: Create a user named John Wiseman and assign him to the Salesforce user license and the Custom: Sales Profile profile.
  2. Create a second user named Paloma Espinoza and assign her to the Salesforce Platform user license and the Standard Platform User profile.
I have not "Salesforce" user license and if I choose "Salesforce Platform" license it tells me there are No Salesforce CRM Content User Licenses Available. 
User-added image

Any thoughts?
I need to update contacts that are chosen on lookup fields on an account to have the same values on custom fields as associated account. 
Background:
  • I have two fields on the Account object that lookup directly to the contact object to house Primary Contact 1 and Primary Contact 2.
  • The Account object has two custom fields Main_Page_Access__c and Sub_Page Access__c.  The Contact object has these same custom fields.
  • I want to run a nightly routine that will update the Main_Page_Access__c, Sub_Page Access__c fields on the Contact object with the values from the Account object.  I need help with the Apex class to do the updates.  
I was able to query the Account and get the Primary Contact 1's ID along with the Account ID and the access fields from the Account and add this to a list.  I then did a second query for the Primary Contact 2 and added that to the list.  Now I want to loop through that list and use the Account Main_Page_Access__c, Sub_Page_Access__c field information to update the contacts Main_Page_Access__c, Sub_Page_Access__c fields.  This is where I am stuck.  Keep in mind that I am new to Apex development...  :-)


***********  Here's my code so far ******************

public with sharing class Assign_Access {

    public static void SelectContactsAndAccess() {

        //Find the Account that have Primary Contacts Associated with them

    //Create a list to hold all primary contacts and access information

        List<Account> AllContacts = new List<Account>();
        AllContacts.clear();

    //Fetch first primary contact and add to PrimaryContact1 list where Primary_Contact1__c holds the Contact ID

        List<Account> PrimaryContact1 = [SELECT Id, Name, Primary_Contact1__c, 
                                             Main_Page_Access__c, Sub_Page_Access__c
                                         FROM Account 
                                         WHERE Primary_Contact__c != NULL ];      

        System.debug('PrimaryContact1 ' + PrimaryContact1);

    //Add Primary Contact 1 to AllContacts list

        AllContacts.addall(PrimaryContact1);

    //Fetch second primary contact and add to PrimaryContact2 list where Primary_Contact2__c holds the Contact ID 

        List<Account> PrimaryContact2 = [SELECT Id, Name, Primary_Contact2__c, 
                                Main_Page_Access__c, Sub_Page_Access__c
                                FROM Account 
                                WHERE Primary_Contact2__c != NULL ]; 

        System.debug('PrimaryContact2 ' + PrimaryContact2);

    //Add Primary Contact 2 to AllContacts list

        AllContacts.addall(PrimaryContact2);

        system.debug('AllContacts '+ AllContacts);

}
}
I'm new to coding and trying to write a test trigger in my dev org.  The trigger needs to fire before insert and compare the name of the course being inserted inot my custom object against the existing courses.  If there is a duplicate course being inserted, throw an error.  Here is what I have so far that is not working.  It gives an error that the comparison if statement of "Variable does not exist: Course_Name__c".  Can someone point me in a direction?

=======TRIGGER CODE+++++

trigger testtr1 on Course__c (before insert) {

Public static void CheckDuplicates(List<Course__c> newCourse){             

      //Create a LIST of all existing courses
    List<Coures__c> ExistingCourses= [SELECT Id, Course_Name__c
                            FROM Course__c];

    
    // Create a SET of all incoming  course names to evaluate
  Set<String> Courses = new Set<String>();
    for (Courses__c s : Trigger.new) {
      Courses.add(s.Course_Name__c);
    } /*end for loop */
    
    //Compare SET values to LIST

      for(Courses__c s : Trigger.new)
            if(
                ExistingCourses.Course_Name__c = s.Course_Name__c)
                s.addError('DUPLICATE COURSE NAME');
  

}  /* end ChecDuplicates method */
}   /*end triggger begin */