Search In This Blog

2021-03-06

Salesforce開発入門タスク3 Apex クラスとVisualforce ページ

簡単で説明すると、Apex クラスはバックエンド(backend)、Visualforce ページはフロントエンド(frontend)ということです。

ApexはJavaと似ています。VisualforceはHTMLと似ています。

Apexの関連勉強tailhead:

https://trailhead.salesforce.com/en/content/learn/modules/apex_database?trail_id=force_com_dev_beginner

https://trailhead.salesforce.com/en/content/learn/modules/apex_testing?trail_id=force_com_dev_beginner


Visualforce ページの関連勉強tailhead:

Visualforce Basics


上記のtailheadを勉強した上に、タスクをはじめます。

目標:Salesforce入門タスク2に作成したオブジェクトのカスタム一覧画面を作成する

事前準備:対象オブジェクトに複数のデータを新規作成する


ステップ1 

対象オブジェクトのVisualforceとApexを新規作成する

Apexでオブジェクトの全て項目取得する。

注意:SELECT * FROM は利用しない、必ず項目のAPI名で取得する


ステップ2

Visualforceに取得した項目を表示する、データ名前を3列で出力する。出力は下記のリンクで参照する

Output data in 3 columns by repeat in Visualforce

プレビューで画面表示の確認できる


ステップ3

Visualforce画面をPDFの形で表示する

How to display Visualforce page as PDF


ステップ4

編集画面のApexとVisualforceを作成する

Apexはステップ1で作成したもの、そのまま利用できるが、ここは新規で作成する。

保存ボタンについて、二重送信防ぐ機能を忘れず。


Salesforce開発入門タスク2 オブジェクト

※ここはClassic部分、Lightning部分は別途となります。

ヘッダーの設定リンクより設定画面を開く



ステップ1

設定>ビルド>作成>オブジェクト


3つカスタムオブジェクトABCを作成し、オブジェクトAと参照関係、主従関係を関連する


ステップ2 オブジェクトのカスタム項目 & リレーション

各オブジェクトがいくつのカスタム項目(全タイプ)を作成する

各項目のプロファイルの権限はデフォルトで設定する


ステップ3 オブジェクトのボタン、リンク、およびアクション


ボタン、リンク、およびアクションにカスタムアクションとボタンを新規作成する

アクションは「メールを送信」で、ボタンは「JavaScriptを実行」で作成する


ステップ4 レイアウト

ページレイアウトを新規作成する

ページレイアウトに新しいセクションを追加する、項目の位置を変更する

ページレイアウトの標準ボタンを削除と編集のみを残る

ステップ2に作成したカスタムアクションとボタンを追加する

保存まだは適用する後、「ページレイアウトの割り当て」よりシステム管理者と標準ユーザに割り当てる


ステップ4 タブ


タブ画面を開く、ステップ1のカスタムオブジェクトタブを作成する

メニュータブの✙をクリックし、作成したタブをクリックする



ステップ5

データを新規作成する


これでカスタムオブジェクトの作成、レイアウトの編集、カスタムボタンとタブの作成について、簡単な入門タスクです。


Salesforce開発入門タスク1

 developアカウントの申請

https://developer.salesforce.com/signup


developアカウントのログイン

https://login.salesforce.com/


役に立つ勉強サイト

https://trailhead.salesforce.com/

Developer Beginner

https://trailhead.salesforce.com/en/content/learn/trails/force_com_dev_beginner

Admin Beginner

https://trailhead.salesforce.com/en/content/learn/trails/force_com_admin_beginner






2021-03-02

ユーザの凍結と無効の違い

 ユーザが凍結すると、ログインができなくなり、パスワードのリセットができます。ライセンスが解除されません。


ユーザが無効すると、ログインはもちろんできなくなり、パスワードのリセットもできなくなります。ライセンスが解除されます。


ユーザがログイン状態中に、システム管理者がユーザを凍結あるいは無効化にすると、ユーザがユーザ認証が必要な画面へ遷移する際、ログイン画面へ遷移されます。

2021-02-26

Call Apex Method with parameter and show result message | Aura

 CMP:

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" controller="InvoiceIssueController" access="global">

<aura:html tag="style">

       .slds-modal__container{ 

         height : auto; width: 80%; max-width: 70vh; 

       } 

       .modal-body{ 

        height : 15vh !important;

        max-height: 15vh !important; 

       } 

       .slds-modal__footer{ 

         display: inline !important; 

       }

    </aura:html>

    

    <aura:handler name="init" value="{!this}" action="{!c.callServer}"/>

    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />

    <aura:attribute name="showErrors" type="String"/>

    <aura:attribute name="errorMessage" type="String"/>

    <aura:attribute name="message" type="String"/>

{!v.message}

    <aura:if isTrue="{!v.showErrors}">       

        <div class="slds-notify slds-notify_toast slds-theme_error">

            <span class="slds-assistive-text">error</span>

            <div class="slds-notify__content">

                <p class="slds-align_absolute-center">{!v.errorMessage}</p>                

            </div>

        </div>

    </aura:if>

</aura:component>


JS:

({

    callServer : function(component,event, helper) {

        var myAttribute = component.get("v.recordId");

        var action = component.get("c.ApexMethod1");

        action.setParams({ "id" : myAttribute });

        var action2 = component.get("c.ApexMethod2");

        action2.setParams({ "id" : myAttribute });


        action2.setCallback(this, function(response) {

            console.log(response.getState());

            if (response.getState() === "SUCCESS") {

                $A.get('e.force:refreshView').fire();           

            }else {

                console.log("Error Saving Contact ");

            }

        });

      

        action.setCallback(this, function(response) {

            if (response.getState() === "SUCCESS") {

                if (response.getReturnValue() == 1) {

                    component.set("v.showErrors",true);

                component.set("v.errorMessage","error!");

                } else {

                    component.set("v.message","process...");

                    $A.enqueueAction(action2);

                }

            }else {                  

                component.set("v.showErrors",true);

                component.set("v.errorMessage","error");

            }

        });

        $A.enqueueAction(action);

    },

    isRefreshed: function(component, event, helper) {

        location.reload();

    }

})


Apex:

Add @AuraEnabled to target ApexMethod