Expression error?!


#1

Hi all!

What’s up with this expression ?

resource : ~ expression "{id: resource == '5E' ? 'electricity' : resource == '5G' ? 'naturalgas' : '' }"

I can provision without errors, then C3 can’t digest the file that is transformed using it.

Error for each line:

Transformation failed: ServiceAgreement.resource.{id: resource == '5E' ? 'electricity' : resource == '5G' ? 'naturalgas' : '' } Error Msg: Invalid expression "{id: resource == '5E' ? 'electricity' : resource == '5G' ? 'naturalgas' : '' }": Not an expression. }

Thank you in advance.


#2

Avoid using empty string for id, the result may be unexpected:

> Facility.create({id: ''})
{id: "df502840-3f57-4e42-8fcc-18b24d230aab", version: 1, meta: C3.t…s.Obj, HDDBase: 20, CDDBase: 26, …}

Can you try adding parenthesis to your expression?


#3

Aben,
Your expression attempts to store a value to field “resource” by evaluating self-referencing “resource” within itself.


#4

I guess the second resource (i.e. source) is from the canonical type that’s been transformed, the first one (i.e. the target) is from the mixed type.