Avatar

Level 3

Hi Everyone,

 

I have a usecase wherein i need to populate one value to other field. Please see below-

CCT_IDbestZip
ID1 
ID1 
ID1 
ID1 
ID112345
ID1 
ID1 
ID1 
ID1 
ID1 

 

I want to populate the zip - 12345 to all the ID1 rows, I tried a code, mentioned below but didn't get it to work yet.

 

var query=xtk.queryDef.create(
<queryDef schema="temp:union" operation="select" lineCount="10000">
<select>
<node expr="@id"/>
<node expr="@CCT_ID"/>
<node expr="@bestZip"/>
<node expr="@newZip"/>
</select>
</queryDef>);

var result = query.ExecuteQuery();

for each (var rec in result.union){

if (rec.@CCT_ID = rec.@CCT_ID){
if (rec.@bestZip != ""){
var value = rec.@bestZip;
logInfo("The value of zip is: " +value);
}
if (rec.@CCT_ID = rec.@CCT_ID){
if (rec.@bestZip = ""){
var newZip = value;
logInfo("The NewZip Value is:" +newZip);
var update=<union xtkschema="temp:union" _operation="update" _key="@id" id={rec.@id}/>
update.@newZip = newZip;

//Write the results to the session
xtk.session.Write(update);
}
}
}