[Salesforce]Using the super Keyword

Using the super Keyword

The super keyword can be used by classes that are extended from virtual or abstract classes. By using super, you can override constructors and methods from the parent class.

parent class:

public virtual class SuperClass {
    public String mySalutation;
    public String myFirstName;
    public String myLastName;

    public SuperClass() {

        mySalutation = 'Mr.';
        myFirstName = 'Carl';
        myLastName = 'Vonderburg';
    }

    public SuperClass(String salutation, String firstName, String lastName) {

        mySalutation = salutation;
        myFirstName = firstName;
        myLastName = lastName;
    }

    public virtual void printName() {

        System.debug('My name is ' + mySalutation + myLastName);
    }

   public virtual String getFirstName() {
       return myFirstName;
   }
}

extended class :

public class Subclass extends Superclass {
  public override void printName() {
        super.printName();
        System.debug('But you can call me ' + super.getFirstName());
    }
}

extended result:

The expected output when calling Subclass.printName is My name is Mr. Vonderburg. But you can call me Carl.

[Salesforce]Salesforce Account Engagement(旧Pardot)とは

Salesforce Account Engagement(旧Pardot)

セールスフォースが提供するマーケティングオートメーション(MA)ツールです。B2B企業向けのツールで、オンライン営業やマーケティング活動の効率化に役立ちます。
【機能】
自社サイトのWebトラッキングやフォーム入力などの顧客の行動履歴を収集する
顧客の興味関心や優先度を把握して営業マンに提供する
見込み客の創出に必要なコンテンツの作成を支援する
ナーチャリングの自動化により、営業部門へ引き渡す見込み顧客の質を向上させる
【Salesforceとの連携】
Salesforceと接続でき、システム間でデータを共有できる
マーケティング部門のデータを営業部門の顧客データとリアルタイムで連携させることができる
Salesforceキャンペーンと密接に連携・管理し、マーケティング施策の実行と効果の可視化を実現する
【導入のポイント】
自社サイトのコンテンツを充実し、狙ったキーワードで検索上位表示する
顧客情報をSales Cloudに集約する
見込み客(リード)数を確保する
有効リードを営業がフォローする体制を準備する

[Salesforce]LWC基礎1

LWC基礎1

LWC構成

lwc
 lwcTest1
  lwcTest1.html
  lwcTest1.js
  lwcTest1.js-meta.xml

lwcTest1.html

<template>
    {testText}
</template>

lwcTest1.js

import { LightningElement } from 'lwc';

export default class LwcTest1 extends LightningElement {
    testText = 'Hello World';
}

lwcTest1.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>63.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

上記のLWCを取引先詳細画面に追加します。

保存します。

有効化します。

取引先詳細画面でLWCが表示されていることを確認します。

[Salesforce]LWC @AuraEnabled()

LWC @AuraEnabled()

LWC で Apex を利用するときは必ず @AuraEnabled()のデコレータが必要です。

public with sharing class ApiSampleController {

    @AuraEnabled(cacheable=true)
    public static Object createRecord() {
        return new Object();
    }

    @AuraEnabled(cacheable=true)
    public static Object getRecords() {
        return new Object();
    }

    @AuraEnabled(cacheable=true)
    public static Object getRecordById() {
        return new Object();
    }

    @AuraEnabled(cacheable=true)
    public static Object updateRecord() {
        return new Object();
    }

    @AuraEnabled(cacheable=true)
    public static Object deleteRecord() {
        return new Object();
    }
}

[Salesforce]RecordType Info Get

RecordType Info Get

Map<String, Map<String, Schema.RecordTypeInfo>> RECORDTYPEMAP = new Map<String, Map<String, Schema.RecordTypeInfo>>();
String sobjectStr = 'Account';
System.debug(Schema.getGlobalDescribe().get(sobjectStr).getDescribe().getRecordTypeInfosByDeveloperName());

{マスター=Schema.RecordTypeInfo[getDeveloperName=マスター;getName=マスター;getRecordTypeId=012000000000000XXX;isActive=true;isAvailable=true;isDefaultRecordTypeMapping=true;isMaster=true;]}

[Salesforce]querySelector()

querySelector()

querySelector()とは、DOM要素を検索するためのメソッドの1つ。
LWC コンポーネントの DOM 要素を取得するために、this.template.querySelector を使用することができます。
これによってどのコンポーネントのDOM要素を取得するのかを指定できます。
要するに、どのコンポーネントのJavascriptから要素を取得するかを指定するものです。

html
<template> 
  <div>AAAAA</div> 
  <div>BBBBB</div> 
</template> 

import { LightningElement } from 'lwc'; 

export default class Example extends LightningElement { 
  renderedCallback() { 
    this.template.querySelector('div'); // return <div>AAAA</div>
    this.template.querySelector('span'); // return null 
    this.template.querySelectorAll('div'); // return [<div>AAAA</div>, <div>BBBB</div>] 
  } 
}

[Technical terms]DOM(Document Object Model)

DOM(Document Object Model)

DOMとはドキュメントオブジェクトモデル (Document Object Model)の略で、Webページの要素やコンテンツなどをツリー構造で表現したデータモデルのことです。

DOMのツリー構造

HTMLの階層に合わせて要素がツリー構造になっています。html、body、h2などの要素はそれぞれオブジェクトです。全てのオブジェクトはツリーの一番上にあるDocumentオブジェクトに含まれています。

[HubSpot]Google App Scriptで会社取得

Google App Scriptで会社取得

const BU = 'https://api.hubapi.com';
const props = PropertiesService.getScriptProperties().getProperties();

function myFunction() {
  const endpoint = `${BU}/crm/v3/objects/companies`;
  const options = {
    'method': 'get',
    'headers' : {
      'Content-Type' : 'application/json',
      'Authorization': 'Bearer '+ props.AT
    },
  };
  const response = UrlFetchApp.fetch(endpoint, options);
  const responseContent = JSON.parse(response.getContentText());
  console.log(responseContent['results'].map(v => {
    return `${v.id}: ${v.properties.name}`
  }));
}