LoginSignup
2
0

Salesforceで関数が対応しているかを調べる方法【Tooling APIをPostmanから使う】

Last updated at Posted at 2023-12-20

Salesforceは入力規則、フロー、数式項目などで関数が使えます。ただ、全ての場所で同じ関数なら必ず使えるとは限りません。経験的にはフローでは使えない関数があると思います。Tooleng APIのオブジェクトを眺めていると関数が対応しているかを確認できそうなオブジェクトの項目があります。

Tooling API Objects/FormulaFunction

IsAllowedInFlowContext
しかし、実際に検索するとそのような項目はないというエラーになりますね。

よく見たらVer 48以降ではFormulaFunctionAllowedTypeに変わったようです。

Removed. Indicates whether the formula function is allowed in a Flow (true) or not (false). This field is available in API versions 39.0 to 47.0. Use the FormulaFunctionAllowedType object instead in API version 48.0 and later.

今回もPostmanを使って確かめたいと思います。
PostmanからSalesforceにアクセスする方法は、以下を参考にして下さい。

FormulaFunctionAllowedTypeオブジェクトの検索

Tooling API Objects / FormulaFunctionAllowedType

qのパラメータに以下を設定します。SOQL文のスペースを+で置き換えた形です。

select+Id,DurableId,FunctionId,Type+from+FormulaFunctionAllowedType+where+FunctionId='ABS'

image.png

検索できました。

image.png

ISNEW() を調べます

select+Id,DurableId,FunctionId,Type+from+FormulaFunctionAllowedType+where+FunctionId='ISNEW'

入力規則でしか使えないようです。

image.png

INCLUDE、IMAGEは検索してもないですね。小文字にしても出てこない。不思議です。

image.png

SUBSTITUTEの使える場所をみると以下のようですが... ver 59.0

{
    "size": 5,
    "totalSize": 5,
    "done": true,
    "queryLocator": null,
    "entityTypeName": "FormulaFunctionAllowedType",
    "records": [
        {
            "attributes": {
                "type": "FormulaFunctionAllowedType",
                "url": "/services/data/v59.0/tooling/sobjects/FormulaFunctionAllowedType/VALIDATION-SUBSTITUTE"
            },
            "Id": "000000000000000AAA",
            "DurableId": "VALIDATION-SUBSTITUTE",
            "FunctionId": "SUBSTITUTE",
            "Type": "VALIDATION"
        },
        {
            "attributes": {
                "type": "FormulaFunctionAllowedType",
                "url": "/services/data/v59.0/tooling/sobjects/FormulaFunctionAllowedType/VISUALFORCE-SUBSTITUTE"
            },
            "Id": "000000000000000AAA",
            "DurableId": "VISUALFORCE-SUBSTITUTE",
            "FunctionId": "SUBSTITUTE",
            "Type": "VISUALFORCE"
        },
        {
            "attributes": {
                "type": "FormulaFunctionAllowedType",
                "url": "/services/data/v59.0/tooling/sobjects/FormulaFunctionAllowedType/FLOW-SUBSTITUTE"
            },
            "Id": "000000000000000AAA",
            "DurableId": "FLOW-SUBSTITUTE",
            "FunctionId": "SUBSTITUTE",
            "Type": "FLOW"
        },
        {
            "attributes": {
                "type": "FormulaFunctionAllowedType",
                "url": "/services/data/v59.0/tooling/sobjects/FormulaFunctionAllowedType/CONVERSATION_MESSAGE-SUBSTITUTE"
            },
            "Id": "000000000000000AAA",
            "DurableId": "CONVERSATION_MESSAGE-SUBSTITUTE",
            "FunctionId": "SUBSTITUTE",
            "Type": "CONVERSATION_MESSAGE"
        },
        {
            "attributes": {
                "type": "FormulaFunctionAllowedType",
                "url": "/services/data/v59.0/tooling/sobjects/FormulaFunctionAllowedType/LOYALTYFORMULA-SUBSTITUTE"
            },
            "Id": "000000000000000AAA",
            "DurableId": "LOYALTYFORMULA-SUBSTITUTE",
            "FunctionId": "SUBSTITUTE",
            "Type": "LOYALTYFORMULA"
        }
    ]
}

Visualizerを試してみます

var template = `
<style>
  .myTable {
    background-color : #dddbda;
  }
  .myTable th{
    width: 400px;
  }
  .myTable td{
    width: 400px;
  }
  </style>


    <table class="myTable">
        <tr>
            <th>Function</th>
            <th>Type</th>
            <th>DurableId</th>
        </tr>

        {{#each response}}
            <tr>
                <td>{{FunctionId}}</td>
                <td>{{Type}}</td>
                <td>{{DurableId}}</td>
            </tr>
        {{/each}}
    </table>
`;

const response = JSON.parse(pm.response.text())
var _ = require('lodash')
var expectedSortedOrder = _.orderBy(response.records, ['Type'],['asc']);
// Set visualizer
pm.visualizer.set(template, {
    // Pass the response body parsed as JSON as `data`
    response: expectedSortedOrder
});

見やすくなりました。

image.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0