Avatar

Level 5

Hi,

Here is an alternative solution with analyze="true" and the variable @<my_enum_var>Label :

// vars.targetSchema = default variable generated by the previous Query activity in a workflow temp:queryExportDriveStatus

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":")+1);

logInfo(schemaName);

var xml =

  <queryDef schema={vars.targetSchema} operation="select" startLine={vars.count} lineCount={vars.batchSize}>

    <select>

      <node expr="@date"/>

      <node expr="@driveStatus" analyze="true"/>

      <node expr="@accountID"/>

      <node expr="@id"/>

    </select>

  </queryDef>;

var query = xtk.queryDef.create(xml);

var res = query.ExecuteQuery()[schemaName];//.queryExportDriveStatus;

var stati = '[';

for each(var status in res){

  stati += '{"account_id":' + status.@accountID + ',"drive_status":"' + status.@driveStatusLabel + '","status_date":"' + formatDate(status.@date, "%4Y%2M%2D") + '","drive_status_id":' + status.@id + ',"topicName":"prod_ingest_adobe_drive_status"},';

}

stati = stati.replace(/,\s*$/, "")+']';

logInfo("STATI : " + stati);