(Salesforce Force.com REST API)如何确定哪些产品与商机相关联?

时间:2015-06-05 16:28:50

标签: rest salesforce

我正在使用Salesforce Force.com REST API。我需要确定哪些产品(Product2)与商机(Opportunity)相关联。到目前为止,我一直无法建立连接。

在Salesofrce用户界面中,机会可以与价格手册和产品相关联。价格手册包含产品,但也可以直接将产品与机会联系起来。

通过API查询商机会产生以下结果:

Array
(
    [0] => Array
        (
            [attributes] => Array
                (
                    [type] => Opportunity
                    [url] => /services/data/v33.0/sobjects/Opportunity/xxxxxxxxxxxxxxxx
                )

            [Id] => xxxxxxxxxxxxxxxx
            [IsDeleted] => 
            [AccountId] => xxxxxxxxxxxxxxxxx
            [Name] => Some Name
            [Description] => 
            [StageName] => Closed Won
            [Amount] => 650
            [Probability] => 100
            [CloseDate] => 2012-04-12
            [Type] => New Business
            [NextStep] => A string
            [LeadSource] => something
            [IsClosed] => 1
            [IsWon] => 1
            [ForecastCategory] => Closed
            [ForecastCategoryName] => Closed
            [CampaignId] => 
            [HasOpportunityLineItem] => 1
            [Pricebook2Id] => xxxxxxxxxxxxxxxxxxxxx
            [OwnerId] => xxxxxxxxxxxxxxxxxxx
            [CreatedDate] => 2012-12-30T20:17:35.000+0000
            [CreatedById] => xxxxxxxxxxxxxxxxxxxxxxxxxxx
            [LastModifiedDate] => 2015-05-22T15:20:18.000+0000
            [LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxxx
            [SystemModstamp] => 2015-05-22T15:20:18.000+0000
            [LastActivityDate] => 
            [FiscalQuarter] => 1
            [FiscalYear] => 2015
            [Fiscal] => 2015 1
            [LastViewedDate] => 2015-06-03T14:38:03.000+0000
            [LastReferencedDate] => 2015-06-03T14:38:03.000+0000
            [SyncedQuoteId] => 
            [Type_of_Deal__c] => Monthly Contract Count
            [Number_of_Contracts__c] => 999
            [Fee_Per_Contract__c] => 999
            [Installation_Fee__c] => 
            [Roof_Top_Fee__c] => 
            [LID__LinkedIn_Company_Id__c] => 
            [inclusion_type__c] => inclusion type
            [Total_Contract_Term__c] => 999
            [Monthly_Value_of_Fee_Per_Contract__c] => 999
            [Total_Value_of_Fee_Per_Contract__c] => 999
            [Total_Value_of_Roof_Top_Fee__c] => 0
            [Monthly_Fidels_Revenue__c] => 999
            [Total_Value_of_Deal__c] => 999
            [Number_of_Roof_Tops__c] => 
            [Monthly_Value_of_Roof_Top_Fee__c] => 0
            [Installation_Date__c] => 2012-01-01
            [Reason_if_Lost__c] => 
            [Total_Monthly_Revenue__c] => 999
            [Existing_Agency__c] => Service Group
            [Number_of_Contracts_in_Last_Batch__c] => 999
            [Agent_Name__c] => John Smith
            [Total_Value_of_Agency_Revenue__c] => 9999
            [Contract_Start_Date__c] => 2012-01-01
            [Batch_Received__c] => Yes
            [Administrator__c] => 
            [Per_Contract__c] => 999
            [Integration_type__c] => 
            [Last_Batch_ID__c] => 
            [Last_Batch_Date__c] => 
        )

)

您可以从中看到没有Product2数据可用。但是,有一个Pricebook2Id。人们可能会认为查询特定的价格手册会产生哪些产品与之相关的信息。但是,查询特定的价格手册会产生以下结果:

Array
(
    [0] => Array
        (
            [attributes] => Array
                (
                    [type] => Pricebook2
                    [url] => /services/data/v33.0/sobjects/Pricebook2/xxxxxxxxxxxx
                )

            [Id] => xxxxxxxxxxxxxxxxxxxx
            [IsDeleted] => 
            [Name] => Company Price Book
            [CreatedDate] => 2011-11-14T18:36:23.000+0000
            [CreatedById] => xxxxxxxxxxxxxxxxxxx
            [LastModifiedDate] => 2011-11-14T18:36:23.000+0000
            [LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxx
            [SystemModstamp] => 2011-11-14T18:36:23.000+0000
            [LastViewedDate] => 2015-06-04T19:41:20.000+0000
            [LastReferencedDate] => 2015-06-04T19:41:20.000+0000
            [IsActive] => 1
            [Description] => 
            [IsStandard] => 
        )

)

如您所见,价格手册中没有关于产品的信息。所以我的问题是:

如何使用Salesforce Force.com REST API确定哪些产品与商机相关联?

1 个答案:

答案 0 :(得分:0)

有一个名为'机会产品'的对象。你需要获得该对象并将适当的机会与产品联系起来。 这是一个多对多的关系而不是一对多,因此不止一个产品可能与每个机会相关,反之亦然。