

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon Connect 客服人員工作區中的自訂視圖
<a name="view-resources-custom-view"></a>

您可以使用 API 建立自己的視圖資源。視圖資源包括 CloudFormation、CloudTrail 和標記支援。

## 檢視 API 範例
<a name="view-resources-custom-view-example"></a>

**檢視說明**

此檢視會將兩張卡片巢狀放入一個容器內，並在其右側放置一個略過按鈕。

**CLI 命令**

```
aws connect create-view --name CustomerManagedCardsNoContainer \
--status PUBLISHED --content file://view-content.json \
--instance-id $INSTANCE_ID --region $REGION
```

**view-content.json**

```
{
  "Template": <stringified-template-json>
  "Actions": ["CardSelected", "Skip"]
}
```

**範本 JSON (未字符串化)**

```
{
    "Head": {
        "Title": "CustomerManagedFormView",
        "Configuration": {
            "Layout": {
                "Columns": ["10", "2"] // Default column width for each component is 12, which is also the width of the entire view.
            }
        }
    },
    "Body": [
        {
            "_id": "card-container",
            "Type": "Container",
            "Props": {},
            "Content": [
                {
                    "_id": "cafe_card",
                    "Type": "Card",
                    "Props": {
                        
                        "Id": "cafe-card",
                        "Heading": "Cafe Card",
                        "Icon": "Cafe",
                        "Status": "Status Field",
                        "Description": "This is the cafe card.",
                        "Action": "CardSelected" // Note that these actions also appear in the view-content.json file.
                          
                    },
                    "Content": []
                },
                {
                    "_id": "no_icon_card",
                    "Type": "Card",
                    "Props": {
                        "Id": "NoIconCard",
                        "Heading": "$.NoIconCardHeading",
                        "Status": "Status Field",
                        "Description": "This is the icon card.",
                        "Action": "CardSelected" // Note that these actions also appear in the view-content.json file.
                    },
                    "Content": []
                }
            ]
        },
        {
            "_id": "button",
            "Type": "Button",
            "Props": { "Action": "Skip" }, // Note that these actions also appear in the view-content.json file.
            "Content": ["Skip"]
        }
    ]
}
```

## 檢視
<a name="view-resources-custom-the-view"></a>

**輸入**

`$.NoIconCardHeading` 代表變更檢視時 `NoIconCardHeading` 欄位為必須輸入項目。

假設 `NoIconCardHeading` 設為 `No Icon Card`。

**外觀**

![\[客服人員工作區檢視卡片的影像。\]](http://docs.aws.amazon.com/zh_tw/connect/latest/adminguide/images/view-resources-custom-the-view.png)


## 檢視輸出範例
<a name="view-resources-custom-view-output-example"></a>

檢視輸出資料的兩個主要部分：獲取的 `Action` 和 `Output` 資料。

將檢視與[顯示檢視](https://docs.aws.amazon.com/connect/latest/adminguide/show-view-block.html)區塊一起使用時，`Action` 代表分支，並將 `Output` 資料設定為 `$.Views.ViewResultData` 流程屬性，如顯示檢視區塊文件中所述。

**情境 1：選擇**咖啡館卡片****

```
"Action": "CardSelected"
"Output": {
    "Heading": "CafeCard",
    "Id": "CafeCard"
}
```

**情境 2：選擇**略過**按鈕**

```
"Action": "Skip"
"Output": {
    "action": "Button"
}
```

## 表單檢視輸出範例
<a name="view-resources-custom-form-view-output-example"></a>

使用 **AWS 管理的檢視 (表單檢視)** 時，表單資料結果會位於 *FormData* 下。

```
{
   FormData: {
       email: "a@amazon.com"
   }
}
```

您可以存取顯示檢視區塊中的資料，例如 `$.Views.ViewResultData.FormData.email`。

使用**自訂檢視 (使用表單元件)** 時，表單資料結果會直接位於輸出下方。

```
{
    email: "a@amazon.com"
}
```

您可以存取顯示檢視區塊中的資料，例如 `$.Views.ViewResultData.email`。