Conditional Stored Calc

#1

What is the best way to implement the following logic?

Two source systems (Source System 1 and Source System 2) feed data into a given type. The data in the two source systems do not overlap: They will never create or modify the same instance of a type.

Source System 1 directly feeds fieldA.

Source System 2 does not directly feed fieldA, instead a calculated expression is needed to a reference type. However, this calculated expression logic will not work for instances of the type that are created from Source System 1.

I would like to do a calculated field with an expression: “if (meta.sourceSystem == Source System 2) {do the calculated expression} Else { do not do the calculated expression }”

Is this possible, or is there another way?

0 Likes

#2

I would recommend 2 transforms, one for instances which are source system 1 and one for instances which are source system 2. That way you can set the same field with different logic in the two cases.

0 Likes

#3

Unfortunately, their is no visibility directly available between Source System 2 and the desired attribute field that is referenced in the proposed calcualted field logic.

Nor is there visibility from the 3rd Source System that populated the attribute field referenced in the calc expression logic to the Type in question.

–The calc expression is 2 data model traverses away.

0 Likes

#4

The following expression should do the trick:

fcalcFieldA: string calc “meta.sourceSystem == ‘Source System 2’ ? calcExpr : null”

0 Likes

#5

the problem is you can’t have a field which is SOMETIMES a stored calc…

I guess you could have:

type Whatever {
fieldForSrc1: string
realField: string stored calc “fieldForSrc1 ? fieldForSrc1: EXPRESSION_FOR_SRC_SYSTEM_2”
}

1 Like