Pattern table empty field population with first row values

Matthew Eames
Tera Expert

Hi,
I'm stuck on a pattern development solution which can't be that hard, surely?
I have a table as a result of parsing a config file in which the first rows fields contain default values and all subsequent rows may or may not be populated. If there is a value I need to keep that value, but if there isnt I need to overwrite that empty field with the first rows default value. E.g.
Start point

 Col1Col2Col3
DefaultOOOOOO
Row1a b
Row2 xy

 

End point

 Col1Col2Col3
DefaultOOOOOO
Row1aOOb
Row2Oxy

 

I've so far attempted Transform Table with javascript field transforms along the lines of

var rtrn = '';
var defVal = ${config[1].Field1};
var currentVal = ${config[].Field1};

if (defVal && !currentVal )
{
rtrn = defVal;
}

but when there is a default value this creates empty fields where there were values before and where there isnt a default value but there is a row value, it empties all values.

Argh.

1 ACCEPTED SOLUTION

Matthew Eames
Tera Expert

Turns out to be simple, wish I could say deceptively simple, but its not deceptive, just simple. Or perhaps thats me. Anyway.

You just need to Transform Table to a new interim table (or your CI table) using a Javascript switch in the Value field for each attribute you want to set. Pretty similar to what I was trying before, but this version works.

var rtn;
if (${config[].Active})
{rtn = ${config[].Active}}
else
{if (${config[1].Active})
rtn = ${config[1].Active}
}

 

View solution in original post

1 REPLY 1

Matthew Eames
Tera Expert

Turns out to be simple, wish I could say deceptively simple, but its not deceptive, just simple. Or perhaps thats me. Anyway.

You just need to Transform Table to a new interim table (or your CI table) using a Javascript switch in the Value field for each attribute you want to set. Pretty similar to what I was trying before, but this version works.

var rtn;
if (${config[].Active})
{rtn = ${config[].Active}}
else
{if (${config[1].Active})
rtn = ${config[1].Active}
}