Salesforce Visualforce Tutorial: Custom Controllers

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

Комментарии • 6

  • @295nick
    @295nick 2 года назад

    Actually good video, thank you

  • @ChrisMarquez
    @ChrisMarquez  2 года назад

    Regarding the error starting at 23:28, the code change we made is actually irrelevant to this issue. I meant to clarify this point later on in the video but I forgot. If we had kept the code as is but instantiated the variables in the constructor, the page would've saved successfully but the contact would not be associated to the account. Everything I said regarding Salesforce assigning record after inserting the record is true. This "Attempt to de-reference a null object" error is exclusively because we had not instantiated the variables.

  • @kbhanuprakash840
    @kbhanuprakash840 2 года назад

    make a playlist on lwc

  • @ПавлеЗорић
    @ПавлеЗорић 8 месяцев назад

    Can I create controller which include more custom objects?

    • @ChrisMarquez
      @ChrisMarquez  8 месяцев назад

      Yes. You can do something like:
      public class MyCustomController {
      // Make sure to define the type of custom object in the variable definition here
      public customObject customObject0__c customObject0 {get; set;}
      public List customObject1List {get; set;}
      public List customObject2List {get; set;}
      // Initialize variables in constructor
      public MyCustomController() {
      //Create new instance of a custom object
      customObject0 = new customObject0__c();
      // Query custom object records
      customObject1List = [SELECT Id, Name, Field1__c FROM CustomObject1__c];
      customObject2List = [SELECT Id, Name, Field2__c FROM CustomObject2__c];
      }
      }