您位於此處:
InsQuoteService:createUpdateQuoteFromExternal
透過外部系統的輸入 API 呼叫,以新資訊建立報價或更新現有報價。
類別:InsQuoteService
方法:createUpdateQuoteFromExternal
運作方式
-
接收 JSON 物件。
-
使用
sourceSystemIdentifier決定要建立或更新現有報價。 -
使用名為「標準」的「
PricebookId」。 -
如果服務找到具有指定
sourceSystemIdentifier的報價,則會更新報價物件:-
使用在
quoteLines中定義的根產品來新增、更新或刪除根報價條列項目。服務會使用sourceSystemIdentifier識別根目錄。新增不在「報價」中
quoteLines的記錄。更新「報價」中存在的quoteLines記錄。刪除在報價中但不在報價行中之quoteLines中的記錄。 -
針對每個根涵蓋範圍,服務會使用在
childLines中定義的涵蓋範圍、受保項目和對象來新增、更新或刪除根涵蓋範圍、受保項目和對象。 服務會使用sourceSystemIdentifier識別要更新的條列。新增不在「報價」中
childLines的記錄。更新「報價」中存在的childLines記錄。刪除在「報價」中但不在「childLines」中的childLines記錄。 -
針對每個基本涵蓋範圍、受保項目和對象,服務會使用在
childLines中的涵蓋範圍、受保項目和對象來新增、更新或刪除各自的涵蓋範圍、受保項目和對象。 服務會使用sourceSystemIdentifier識別要更新的線路。新增不在「報價」中
childLines的記錄。更新「報價」中存在的childLines記錄。刪除在「報價」中但不在「childLines」中的childLines記錄。 -
主要受保項目的
QuoteLineItem和子系受保當事人QuoteLineItem記錄具有 many:many 關係。這些關係會儲存在「報價項目關係」(QuoteItemRelationship__c) 物件中。如果保險項目QuoteLineItem與多個受保當事人QuoteLineItem記錄有關係,則服務會使用PrimaryChildLineItemId__c欄位來判斷哪一個關係是主要關係。例如,Joan Smith 和 John Smith 都是 Lexus 250 的駕駛員;Joan Smith 已設定為主要駕駛員。Lexus 250
QuoteLineItem的PrimaryChildLineItemId__c指向 Joan Smith 的QuoteLineItem。 -
如果兩個受保項目擁有相同的子系受保人,則每個受保項目在個別的子系受保人
childLines中必須有項目。兩個項目必須有相同的sourceSystemIdentifier。例如,Lexus 250 和 Honda Odyssey 都有 Bob Jones 作為司機。 Lexus 250 具有 Bob Jones,其
childLines中的sourceSystemIdentifier是 BobJones。 Honda Odyssey 有 Bob Jones,其childLines中的sourceSystemIdentifier扮演 BobJones。 -
childLines的 ParentItemId__c 和 ParentItemId2__c 指向根識別碼。 -
子系保險的
SubParentItemId__c指向主要受保項目。
-
-
如果服務找不到具有指定
sourceSystemIdentifier的報價,則會建立包含條列項目的報價物件,如下所述:-
使用在
quoteLines中定義的根產品建立根報價條列項目。 -
針對每個根涵蓋範圍,使用在
childLines中定義的涵蓋範圍、受保項目和對象,以建立根涵蓋範圍、受保項目和對象。 -
針對每個基本涵蓋範圍、受保項目和對象,使用涵蓋範圍、受保項目和在其
childLines中定義的對象建立其涵蓋範圍、受保項目和對象。 -
主要受保項目的
QuoteLineItem和子系受保當事人QuoteLineItem記錄具有 many:many 關係。這些關係會儲存在「報價項目關係」(QuoteItemRelationship__c) 物件中。如果保險項目QuoteLineItem與多個受保當事人QuoteLineItem記錄有關係,則服務會使用PrimaryChildLineItemId__c欄位來判斷哪一個關係是主要關係。例如,Joan Smith 和 John Smith 都是 Lexus 250 的駕駛員;Joan Smith 已設定為主要駕駛員。Lexus 250
QuoteLineItem的PrimaryChildLineItemId__c指向 Joan Smith 的QuoteLineItem。 -
如果兩個受保項目擁有相同的子系受保者,則每個受保項目必須在子系受保者的個別
childLines中有項目。兩個項目必須有相同的sourceSystemIdentifier。例如,Lexus 250 和 Honda Odyssey 都有 Bob Jones 作為司機。 Lexus 250 擁有 Bob Jones,其
childLine中包含sourceSystemIdentifier作為 BobJones。 Honda Odyssey 擁有 Bob Jones,其childLines中具有sourceSystemIdentifier角色為 BobJones。 -
childLines的ParentItemId__c和ParentItemId2__c指向根識別碼。 -
子系保險的
SubParentItemId__c指向主要受保項目。
-
-
傳回輸出 JSON 中發生錯誤的
Quote.Id與清單。
輸入
輸入 |
描述 |
|---|---|
|
包含建立報價的所有資訊。如需金鑰值配對的詳細資訊,請參閱 JSON 節點描述。 |
JSON 節點描述 |
|
|
記錄清單。服務只會在指定的時間處理一個報價。 |
報價節點 |
|
|
必要。 機會的識別碼。 |
|
必要。 Salesforce 外部系統的唯一記錄識別碼,可識別要更新的報價。 |
|
報價記錄類型的 API 名稱。 |
|
您要填入之其他 |
|
根產品清單。 |
quoteLines nodes |
|
|
必要。 Salesforce 外部系統的唯一記錄識別碼,可識別要在 Salesforce 中新增、更新或刪除的 QuoteLineItems 根。 |
|
根產品的 |
|
必要。 根產品代碼。 |
|
必要。 產品或規格記錄類型。 |
|
選取的產品屬性。 |
|
您要填入之其他 |
|
根產品涵蓋範圍、受保項目和受保者。 |
childLines nodes |
|
|
必要。 Salesforce 外部系統的唯一記錄識別碼,可識別要在 Salesforce 中新增、更新或刪除的根涵蓋範圍、受保項目和受保對象。 |
|
識別相同規格的多個例項。 受保項目和受保者之 |
|
必要。 基本涵蓋範圍、受保項目和受保者的產品代碼。 |
|
必要。 產品或規格記錄類型。 |
|
選取的產品屬性。 |
|
您要填入之其他 |
|
子系保險、受保項目和受保者。 |
childLines nodes |
|
|
必要。 Salesforce 外部系統的唯一記錄識別碼,可識別要在 Salesforce 中新增、更新或刪除的子系涵蓋範圍、受保項目和受保對象。 如果兩個受保項目擁有相同的子系受保者,則每個受保項目必須在子系受保者的個別 |
|
識別相同規格的多個例項。 受保項目和受保者之 |
|
必要。 子系保險、受保項目和受保方產品的產品代碼。 |
|
必要。 產品或規格記錄類型。 |
|
選取的產品屬性。 |
|
您要填入之其他 |
輸入 JSON
以下是輸入 JSON 的格式:
{
"quote":{
"records":[
{
"opportunityId":"Opportunity.Id",
"sourceSystemIdentifier":"Id",
"sourceSystem":"Name of system quote was created",
"Name":"Quote Name",
"type":"Quote.RecordType.DeveloperName",
"effectiveDate":"Quote.EffectiveDate__c",
"endDate":"Quote.EndDate__c",
"price":Quote.StandardPremium__c,
"term":"Quote.Term__c",
"status":"Quote.Status",
"additionalFields":{
"Quote.fieldAPIName":"value"
},
"quoteLines":{
"records":[
{
"sourceSystemIdentifier":"Id",
"lineRecordType":"Product2",
"instanceKey":"name",
"productCode":"Product2.ProductCode",
"productName":"Product2.Name",
"attributeCategories":{
"records":[
{
"productAttributes":{
"records":[
{
"code":"attribute code",
"userValues":"selected value"
}
]
}
}
]
},
"additionalFields":{
"QuoteLineItem.fieldAPIName":"value"
},
"childLines":{
"records":[
{
"sourceSystemIdentifier":"Id",
"lineRecordType":"Product2.RecordType.DeveloperName",
"productCode":"Product2.ProductCode",
"productName":"Product2.Name",
"instanceKey":"instance name",
"price":QuoteLineItem.UnitPrice,
"taxAmount":QuoteLineItem.TaxAmount__c,
"feeAmount":QuoteLineItem.FeeAmount__c,
"additionalFields":{
"QuoteLineItem.fieldAPIName":"value"
},
"attributeCategories":{
"records":[
{
"productAttributes":{
"records":[
{
"code":"attribute code",
"userValues":"selected value"
}
]
}
}
]
},
"childLines":{
"records":[
{
"sourceSystemIdentifier":"Id",7e54f959544f",
"lineRecordType":"InsuredPartySpec",
"productCode":"Product2.ProductCode",
"productName":"Product2.Name",
"instanceKey":"instance name",
"price":QuoteLineItem.UnitPrice,
"taxAmount":QuoteLineItem.TaxAmount__c,
"feeAmount":QuoteLineItem.FeeAmount__c,
"isPrimaryChild":true,
"additionalFields":{
"QuoteLineItem.fieldAPIName":"value"
},
"attributeCategories":{
"records":[
{
"productAttributes":{
"records":[
{
"code":"attribute code",
"userValues":"selected value"
}
]
}
}
]
}
}
]
}
}
]
}
}
]
}
}
]
}
}以下是輸入 JSON 的範例:
{
"quote": {
"records": [
{
"opportunityId": "0065w0000286hhNAAQ",
"sourceSystemIdentifier": "af3c0072-9018-43df-83d3-3a5f254d5b1e",
"sourceSystem": "Salesforce",
"Name": "Auto Root (External)",
"type": "LargeGroupQuote",
"effectiveDate": "06/01/2021",
"endDate": "12/01/2021",
"price": 10000,
"term": "Semi-Annual",
"status": "Submitted",
"quoteLines": {
"records": [
{
"sourceSystemIdentifier": "49553393-120a-4777-b65a-8167c386a0fb",
"instanceKey": "Auto Root",
"productCode": "AUTOROOT",
"productName": "Auto Root",
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "atLimitUM",
"userValues": 200
}
]
}
}
]
},
"additionalFields": {
"instest12__AdjustmentComments__c": "test comment"
},
"childLines": {
"records": [
{
"sourceSystemIdentifier": "5a8d1b04-c34c-6a48-42c8-ab08be9868e1",
"lineRecordType": "InsuredItemSpec",
"Name": "Auto",
"productName": "Auto",
"productCode": "AUTO",
"instanceKey": "2010 Honda Odyssey",
"price": 111,
"taxAmount": 5,
"feeAmount": 21,
"additionalFields": {
"instest12__AdjustmentComments__c": "test comment"
},
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "autoYear",
"userValues": 2010
},
{
"code": "carValue",
"userValues": 55000
},
{
"code": "est_annual_mileage",
"userValues": 2000
},
{
"code": "autoMake",
"userValues": "Honda"
},
{
"code": "autoModel",
"userValues": "Odyssey"
}
]
}
}
]
},
"childLines": {
"records": [
{
"sourceSystemIdentifier": "6400140b-3e97-32c4-bdfd-7e54f959544f",
"lineRecordType": "InsuredPartySpec",
"Name": "Driver",
"productName": "Driver",
"productCode": "DRIVER",
"instanceKey": "Bob Jones",
"price": 112,
"taxAmount": 6,
"feeAmount": 22,
"isPrimaryChild": true,
"additionalFields": {
"instest12__AdjustmentComments__c": "test comment"
},
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "AGE",
"userValues": 24
},
{
"code": "FN",
"userValues": "Bob"
},
{
"code": "LN",
"userValues": "Jones"
},
{
"code": "GENDER",
"userValues": "Male"
}
]
}
}
]
}
},
{
"sourceSystemIdentifier": "38c4fe27-7b85-77ce-c9e2-1f7f22889982",
"lineRecordType": "InsuredPartySpec",
"Name": "Driver",
"productName": "Driver",
"productCode": "DRIVER",
"instanceKey": "Joan Smith",
"price": 113,
"taxAmount": 7,
"feeAmount": 23,
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "AGE",
"userValues": 25
},
{
"code": "FN",
"userValues": "Joan"
},
{
"code": "LN",
"userValues": "Smith"
},
{
"code": "GENDER",
"userValues": "Female"
}
]
}
}
]
}
},
{
"sourceSystemIdentifier": "33b74fa2-fba5-44b4-317f-021dae689a9f",
"lineRecordType": "CoverageSpec",
"Name": "Collision Deductible Waiver",
"productName": "Collision Deductible Waiver",
"productCode": "COL_WAIVER",
"instanceKey": "2010 Honda Odyssey_COL_WAIVER",
"price": 114,
"taxAmount": 8,
"feeAmount": 24
},
{
"sourceSystemIdentifier": "c4d5ac35-99b1-047d-cebe-05b74861463e",
"lineRecordType": "CoverageSpec",
"Name": "Uninsured/Underinsured Motorist BI",
"productName": "Uninsured/Underinsured Motorist BI",
"productCode": "UNINSURED_COVERAGE",
"instanceKey": "2010 Honda Odyssey_UNINSURED_COVERAGE",
"price": 115,
"taxAmount": 9,
"feeAmount": 25,
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "AbaThrpyOutptInst_covered_inn",
"userValues": 1.3
},
{
"code": "UNINSURED",
"userValues": "No coverage"
}
]
}
}
]
}
}
]
}
},
{
"sourceSystemIdentifier": "60699eaf-956a-4381-8ef2-5a704c85517f",
"lineRecordType": "InsuredItemSpec",
"Name": "Auto",
"productName": "Auto",
"productCode": "AUTO",
"instanceKey": "2011 Toyota Camry",
"price": 116,
"taxAmount": 10,
"feeAmount": 26,
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "autoYear",
"userValues": 2011
},
{
"code": "carValue",
"userValues": 55500
},
{
"code": "est_annual_mileage",
"userValues": 2200
},
{
"code": "autoMake",
"userValues": "Toyota"
},
{
"code": "autoModel",
"userValues": "Camry"
}
]
}
}
]
},
"childLines": {
"records": [
{
"sourceSystemIdentifier": "6400140b-3e97-32c4-bdfd-7e54f959544f",
"lineRecordType": "InsuredPartySpec",
"Name": "Driver",
"productName": "Driver",
"productCode": "DRIVER",
"instanceKey": "Bob Jones",
"price": 112,
"taxAmount": 6,
"feeAmount": 22,
"isPrimaryChild": true,
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "AGE",
"userValues": 24
},
{
"code": "FN",
"userValues": "Bob"
},
{
"code": "LN",
"userValues": "Jones"
},
{
"code": "GENDER",
"userValues": "Male"
}
]
}
}
]
}
},
{
"sourceSystemIdentifier": "8c450354-2053-444c-9c9e-36a66e6f5582",
"lineRecordType": "CoverageSpec",
"Name": "Collision Deductible Waiver",
"productName": "Collision Deductible Waiver",
"productCode": "COL_WAIVER",
"instanceKey": "2011 Toyota Camry_COL_WAIVER",
"price": 117,
"taxAmount": 11,
"feeAmount": 27
},
{
"sourceSystemIdentifier": "7aaeee37-05ce-4926-accb-dff2ee85587f",
"lineRecordType": "CoverageSpec",
"Name": "Roadside",
"productName": "Roadside",
"productCode": "ROADSIDE_COVERAGE",
"instanceKey": "2011 Toyota Camry_ROADSIDE_COVERAGE",
"price": 118,
"taxAmount": 12,
"feeAmount": 28,
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"code": "ROADSIDE",
"userValues": 1
}
]
}
}
]
}
}
]
}
}
]
}
}
]
},
"additionalFields": {
"instest12__MonthlyPremium__c": 222
}
}
]
}
}輸出 JSON
傳回輸出 JSON 中已建立或更新的報價 Quote.Id,以及發生錯誤的清單。
以下是輸出 JSON 的格式:
{
"errors":[
"error1",
"error2",
"error3"
],
"quoteId":"Quote.Id"
}{
"errors":[
"Failed to create/update QuoteLineItem Honda Odyssey.Required fields are missing: [PricebookEntryId, Product2Id]; ",
"Failed to create/update QuoteLineItem Toyota Camry.Required fields are missing: [PricebookEntryId, Product2Id]; ",
"Failed to create/update QuoteLineItem Patty Desc.Required fields are missing: [PricebookEntryId, Product2Id]; "
],
"quoteId":"0Q05w0000027aH5CAI"
}