How to access VariableSet's variables in Record Procuder Scripts.

Hrishabh Kumar
Giga Guru

I created a record producer for cmdb_ci_server[Server] table, in which I created 2 variables and 1 variable set.

I want to map these variables & variableSet's variables to cmbd_ci_server[Server] tables fields. 

 

I want answers to the following questions:

1) How can we map variableSet's variables without writing script? (if there is a no-code approach).

2) How to access variableSet's variables in script? (ie.. we access normal variables like "producer.<variable_name>").

3) Which is the most optimized way of mapping record producers variables with target table fields? (manual mapping or scripting)

1 ACCEPTED SOLUTION

Hrishabh Kumar
Giga Guru

We can access variableSet's varibales like:  producer.<variableSet_name>.<varibale_name>

 

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

There are two type of Variable Sets - single row, and multi row.  With both, there is not a no-code method to map the variables to a field.  In your producer Script, for a single row variable set, treat it as you would any other variable with the syntax

current.field_name = producer.variable_name;

A multi-row variable set requires a few more lines as you have to loop through the value for each row, so let me know if that's what you're dealing with, then you have to decide how you want to handle the mapping of multiple values to a single value field.

 

For variables outside of a variable set, it's always best to use the non-scripting method if it's a basic mapping with no lookup/manipulation needed as you are selecting the field by name rather than typing in the field name and variable name, so there's less room for error.

 

yes! I want to access variableSet's variable. how can we access them in record producer scripts.

rest was helpful!!

Hrishabh Kumar
Giga Guru

We can access variableSet's varibales like:  producer.<variableSet_name>.<varibale_name>

 

And how can we access variable set's > variable using catalog client script in catalog iten.