์™ธ๋ถ€ (External)

์ฃผ๋กœ ์™ธ๋ถ€ ์„œ๋ฒ„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•˜์—ฌ ๊ฐ™์ด ํ‘œํ˜„ํ•ด์ฃผ๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์ž‘์„ฑํ•œ Apex Class๋ฅผ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ๋•Œ๋ฌธ์— ๋‚ด๋ถ€ ๋ฐ์ดํ„ฐ์†Œ์Šค์— ๋น„ํ•ด ์ž์œ ๋กญ๊ฒŒ ๋ฐ์ดํ…Œ๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” ์žฅ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ์™ธ๋ถ€ ์„œ๋ฒ„์—์„œ ์‹ค์‹œ๊ฐ„ ์žฌ๊ณ ๋ฅผ ๊ฐ€์ ธ์™€ ํ™”๋ฉด์— ๊ฐ™์ด ํ‘œ์‹œํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ Apex Class์—์„œ Rest API ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์™ธ๋ถ€ ๋ฐ์ดํ„ฐ์†Œ์Šค์— ์ง€์ •ํ•˜๋ฉด Line-Item Configurator์—์„œ ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์†์„ฑ

    External ๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ ์†์„ฑ์ž…๋‹ˆ๋‹ค.

  • Apex Class ์ž‘์„ฑ

    External ๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „ Apex Class๋ฅผ ๋จผ์ € ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Package์—์„œ ์ œ๊ณตํ•˜๋Š” SBLD.DataSourceService.Fetchable ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ž‘์„ฑํ•˜๋ ค๋Š” Apex Class์— implements ํ•˜์—ฌ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

  • ์˜ˆ์‹œ

    ์ค€๋น„์ค‘์ž…๋‹ˆ๋‹ค.


์†์„ฑ

External ๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ ์†์„ฑ์ž…๋‹ˆ๋‹ค.

๋ฒˆํ˜ธํ•„๋“œ๋ช… ๋ฐ ์˜์—ญ์„ค๋ช…ํ•„์ˆ˜

1

External ์œ ํ˜• ์„ ํƒ

External ๋ฐ์ดํ„ฐ์†Œ์Šค ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ์‹์€ ๋‘ ๊ฐ€์ง€ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.

  • Apex - SBLD.DataSourceService.Fetchable ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•œ Apex Class๋ฅผ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.

  • Flow - ์ž๋™์‹คํ–‰ ํ”Œ๋กœ๋ฅผ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.

โœ”๏ธ

2

ํ™œ์„ฑํ™”

๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. ํ™œ์„ฑํ™”๊ฐ€ ๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฉด ๋ฆฌ์ŠคํŠธ ๊ตฌ์„ฑ ์‹œ ์ž‘๋™๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

3

Description

๋ฐ์ดํ„ฐ์†Œ์Šค์— ๋Œ€ํ•œ ์„ค๋ช…์„ ๊ธฐ์ž…ํ•ฉ๋‹ˆ๋‹ค.

4

Key Field

๋ฐ์ดํ„ฐ์†Œ์Šค์—์„œ ๊ฐ€์ ธ์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฆฌ์ŠคํŠธ ์ง€์ • ๊ฐœ์ฒด์˜ ์–ด๋– ํ•œ ํ•„๋“œ๊ฐ’์œผ๋กœ ๊ฒฐํ•ฉํ• ์ง€ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

โœ”๏ธ

5

Parameters

๋ฐ์ดํ„ฐ์†Œ์Šค์— ๋ฆฌ์ŠคํŠธ ์ง€์ • ๊ฐœ์ฒด์˜ ํ•„๋“œ ๊ฐ’์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ํ•„๋“œ๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

6

Input Variable

7

Output Variable

โœ”๏ธ

Apex Class ์ž‘์„ฑ

External ๋ฐ์ดํ„ฐ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „ Apex Class๋ฅผ ๋จผ์ € ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Package์—์„œ ์ œ๊ณตํ•˜๋Š” SBLD.DataSourceService.Fetchable ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ž‘์„ฑํ•˜๋ ค๋Š” Apex Class์— implements ํ•˜์—ฌ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

SBLD.DataSourceService.Fetchable ํด๋ž˜์Šค๋ฅผ implements ํ•˜์—ฌ execute() ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

DataSourceServiceMock.cls
global with sharing class DataSourceServiceMock implements SBLD.DataSourceService.Fetchable {
    /***
     * @description SBLD.DataSourceService.Fetchable execute() ์ •์˜
     * @param param SBLD.DataSourceService.Parameterํ˜• ํŒŒ๋ผ๋ฏธํ„ฐ
     *              DataSource์—์„œ ์„ค์ •ํ•œ 
     * @return Map<Object, SObject>
     ****/
    global SBLD.DataSourceService.Result execute(SBLD.DataSourceService.Parameter param) {
        SBLD.DataSourceService.Result results = new SBLD.DataSourceService.Result();
        /**
         *  @method DataSourceService.Parameter gets()
         *  @param  String ํ˜• Parent, Lookup ์ค‘ ์„ ํƒ (๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ ์—†์Œ)
         *  @return List<SObject>
         **/
        SObject parentRecord = null;
        List<SObject> lookupRecords = new List<SObject>();
        // Parent ๊ด€๋ จ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
        if(param.gets('parent')<>null && !param.gets('parent').isEmpty()) {
            parentRecord = param.gets('parent')[0];
        }
        // Lookup ๊ด€๋ จ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
        if(param.gets('lookup')<>null && !param.gets('lookup').isEmpty()) {
            listLookupParameters = param.gets('lookup');
        }
        /**
         * ์„ฑ๊ณต ์‹œ, External ๊ฒฐ๊ณผ๊ฐ’์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
         **/
        for(SObject sobj : lookupRecords) {
            /**
             * Internal์˜ Action๊ณผ ๋™์ผํ•˜๊ฒŒ DataSource์˜ ๊ฐ’์„ 
             * Lookup ๋˜๋Š” Line-Item ํ•„๋“œ์— ๋งคํ•‘ํ•˜๋Š” ์ž‘์—…์„ 
             **/
            SBLD.DataSourceServiceAction action = new SBLD.DataSourceServiceAction();
            // 1. External์— ์„ค์ •ํ•œ External Key ๊ฐ’
            action.setKeyValue(sobj.get('Id')); // Product Code
            // 2. External์—์„œ ๊ฐ€์ ธ์˜จ ๊ฐ’์„ Lookup ๋˜๋Š” Junction ํ•„๋“œ์— ๋งคํ•‘ํ•ฉ๋‹ˆ๋‹ค.
            Map<String, Object> mapPopulatedField = sobj.getPopulatedFieldsAsMap();
            for(String fieldName : mapPopulatedField.keySet()) {
                action.putSourceToTargetField(mapPopulatedField.get(fieldName), fieldName);
            }
            // 3. DataSourceService.Result์— Action์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
            results.addAction(action);
        }
        return results;
    }
}

SBLD.DataSourceService.Parameter์—์„œ gets() ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด Line-Item Configurator์˜ Parent ๋˜๋Š” Lookup ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

global SBLD.DataSourceService.Result execute(SBLD.DataSourceService.Parameter param) {
    SObject parentRecord = null;
    List<SObject> lookupRecords = new List<SObject>();
    // Parent ๊ด€๋ จ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
    if(param.gets('parent')<>null && !param.gets('parent').isEmpty()) {
        parentRecord = param.gets('parent')[0];
    }
    // Lookup ๊ด€๋ จ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
    if(param.gets('lookup')<>null && !param.gets('lookup').isEmpty()) {
        listLookupParameters = param.gets('lookup');
    }
    ...
}

Line-Item Configurator๋กœ ๊ฒฐ๊ณผ๊ฐ’์„ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜ ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.

SBLD.DataSourceServiceAction Class

๋Œ€์ƒ(Lookup ๋˜๋Š” Line-Item)์˜ ํ–‰๋งˆ๋‹ค Action์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. Action์€ ๋ฐ์ดํ„ฐ์†Œ์Šค ๊ฐ’์„ Lookup ๋˜๋Š” Line-Item ํ•„๋“œ์— ๋งคํ•‘ํ•˜๋Š” ์ž‘์—…์ž…๋‹ˆ๋‹ค.

  • setKeyValue(Object keyValue) Lookup ๋˜๋Š” Line-Item์˜ ๋Œ€์ƒ ๋ ˆ์ฝ”๋“œ๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•œ Key๊ฐ’์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • putSourceToTargetField(Object sourceValue, String targetField) ๋ฐ์ดํ„ฐ์†Œ์Šค ๊ฐ’์„ Lookup ๋˜๋Š” Line-Item ํ•„๋“œ์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.

SBLD.DataSourceService.Result Class

๋งคํ•‘์ด ์™„๋ฃŒ๋œ Action์„ ๋ฆฌํ„ด ๊ฐ’์— ์ถ”๊ฐ€ํ•˜๋Š” ์ž‘์—…์ž…๋‹ˆ๋‹ค.

  • addAction(SBLD.DataSourceServiceAction action) SBLD.DataSourceService.Result ์ธ์Šคํ„ด์Šค์— Action์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

...
SBLD.DataSourceService.Result result = new SBLD.DataSourceService.Result();
for(Object objResponse : listResponses) {
    Map<String, Object> mapResponse = (Map<String, Object>)objResponse;

    SBLD.DataSourceServiceAction action = new SBLD.DataSourceServiceAction();
    // ๋ฐ์ดํ„ฐ์†Œ์Šค์—์„œ ์„ค์ •ํ•œ Key ํ•„๋“œ์— ์•Œ๋งž๋Š” ๊ฐ’
    action.setKeyValue(mapResponse.get('Id')); // Product Code
    // ๋ฐ์ดํ„ฐ์†Œ์Šค์—์„œ ๊ฐ€์ ธ์˜จ ๊ฐ’์„ Lookup ๋˜๋Š” Line-Item ํ•„๋“œ์— ๋„ฃ๊ธฐ
    action.putSourceToTargetField(mapResponse.get('inventory'), 'Inventory__c');
    // SBLD.DataSourceService.Result์— Action์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
    result.addAction(action);
}
return result;

์˜ˆ์‹œ

์ค€๋น„์ค‘์ž…๋‹ˆ๋‹ค.

Last updated