JS object fields in expressions

Avatar

Avatar

eriku40433679

Avatar

eriku40433679

eriku40433679

09-07-2017

Hi all,

I'm building a lookup javascript object whose values I want to use in an enrichment activity as a calculated field. Here's an example of what i want to happen

Variable:

instance.vars.variableA={key:'value'};

---

Expression

$(instance/vars/@variableA[@columnFromTargetingDimension])

Hope I'm making sense. I need to read the associated value from the javascript object based on a field from the targeting dimension but i'm having problems with the syntax or if this is possible in the first place. I'm also open to other approaches as well except for enumerations for reasons I won't get into.

Thanks,

--Erik

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

MarcelSzimonisz

MVP

Avatar

MarcelSzimonisz

MVP

MarcelSzimonisz
MVP

15-07-2017

Hello Erik,

"The variables are the free properties of the instance, task and event objects. The JavaScript types authorized for these variables are string, number and Date"

So you cannot save other than date,number or string object in to the instance variable.

But you might try SQL activity where you save your object to json string in the advanced tab

var variableA = {label:"auto",field:"sLabel"};

//to string

instance.vars.variableA = JSON.stringify(variableA);

And then nicely put back to object in the SQL activity

<%

  var variableA = JSON.parse(instance.vars.variableA);

%>

INSERT INTO <%= vars.tableName %> (<%= variableA.field %>) SELECT <%= variableA.field %> FROM XtkWorkflow where <%= variableA.field %> LIKE '%<%= variableA.label %>%'

But how you do the rest I do not know....good luck

Marcel

Answers (1)

Answers (1)

Avatar

Avatar

eriku40433679

Avatar

eriku40433679

eriku40433679

18-07-2017

Ahh. That's why. I've gone a different route to solve my problem but this is good to keep in mind for future implementations. Thanks for the help Marcel.

Cheers!

--Erik