我很难找到解决以下问题的方法,任何人都可以建议采用高级方法。
使用talend,我有一组帐户的输入值集(来自CSV):
AccountId, ValueXYZ__c
我想将ValueXYZ存储在SFDC帐户中,这没有问题,但是我想为所有具有相同父级的帐户累计ValueXYZ Account.Parent.TotalValueXYZ
然后我想在帐户层次结构中“滚动”这个:
想象一下帐户层次结构:
A
-B
--C
--D
-E
--F
--G
我想要A上的3个值:
ValueXYZ = account A's ValueXYZ
TotalValueXYZ = total of ValueXYZ values for all accounts under A in the hierarchy
TOTAL = formula field to add together the previous 2 values
我希望帐户B上有3个值
ValueXYZ = account B's ValueXYZ
TotalValueXYZ = total of ValueXYZ values for accounts C & D
TOTAL = formula field to add together the previous 2 values
我想要帐户C上的3个值
ValueXYZ = account C's ValueXYZ
TotalValueXYZ = 0
TOTAL = formula field to add together the previous 2 values
我尝试了几种方法,但无法让它们起作用!
答案 0 :(得分:0)
存储层次结构信息在哪里?如果您可以以键值对格式展平层次结构信息,那么它很简单。只需读取输入文件并在层次结构文件上执行查找/连接。你将不得不循环直到你到达基本记录
答案 1 :(得分:0)
我的问题的关键在于不了解层次结构中的每个帐户位置。一旦我有了这个,我就可以从最低级别循环到最高级别,将这些值总计为父母。
这是我写的用于标记每个帐户的层次结构位置(HILEVEL)的T-SQL
TRUNCATE TABLE [TALEND_WORKSPACE].[dbo].[SFDCAccount]
INSERT INTO [TALEND_WORKSPACE].[dbo].[SFDCAccount] (Id, ParentId, QCIYTDOneTime, QCIYTDRecurring, HILEVEL)
SELECT Id, ParentId, ValueXYZ, '0'
FROM [TALEND_WORKSPACE].[dbo].[SFDCAccountRawData]
WHERE ParentId = ' ';
USE TALEND_WORKSPACE
IF OBJECT_ID('dbo.sfdcaccounthierarchy', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[sfdcaccounthierarchy];
GO
CREATE PROCEDURE [dbo].[sfdcaccounthierarchy]
AS
DECLARE @v_counter int;
DECLARE @v_lastccounter int;
DECLARE @v_max int;
SET @v_counter = 0;
SET @v_lastccounter = 0;
SET @v_max = 10;
WHILE (@v_counter < @v_max)
BEGIN
SET @v_lastccounter = @v_counter;
SET @v_counter = @v_counter+1;
PRINT @v_counter;
INSERT INTO [dbo].[SFDCAccount] (Id, ParentId, QCIYTDOneTime, QCIYTDRecurring, HILEVEL)
SELECT Id, ParentId, ValueXYZ, @v_counter
FROM [TALEND_WORKSPACE].[dbo].[SFDCAccountRawData]
WHERE ParentId IN (SELECT Id FROM [TALEND_WORKSPACE].[dbo].[SFDCAccount]
WHERE HILEVEL = @v_lastccounter);
if @@ROWCOUNT != 0
BREAK;
END
GO
EXEC [TALEND_WORKSPACE].[dbo].[sfdcaccounthierarchy];