• fer r
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I can't remember if the best practice is  to comment out unused code applied to only Apex or  javascript as well.
  • April 04, 2018
  • Like
  • 0
I can't remember if the best practice is  to comment out unused code applied to only Apex or  javascript as well.
  • April 04, 2018
  • Like
  • 0
public without sharing class CreateContactController {

    @AuraEnabled
    public static Id createRecord (Contact contact){
        System.debug('Inserting contact with:' + contact.FirstName + contact.LastName + contact.Email);
        Id returnID = null;        
        if(contact != null){
      User u = [SELECT Id, Contact.AccountId FROM User WHERE Id = :UserInfo.getUserId()][0];
            contact.AccountId = u.Contact.AccountId;
            insert contact;
            returnId = contact.Id;
        }
        else {
            System.debug('Could not insert.');
        }
        return returnId;
    }

}