JS to return schema? | Community
Skip to main content
RaulOcana
Level 3
Jun 21, 2019 9:24 PM UTC
Solved

JS to return schema?

Hi guys,

Is it possible to Query a schema, send it to a Javascript to apply a <where> condition and then return the schema result, therefore send it to another flow activity? I have tried it without result.

Here's my js

query = xtk.queryDef.create(

  <queryDef schema={vars.targetSchema} operation="select" distinct="true" noLineCount="1">

    <select>

      <node expr="@field1" alias="field1"/>

    </select>

    <where>

      <condition expr={"@field1='" + localVar + "'"}/>

    </where>

  </queryDef>);

resultSet = query.ExecuteQuery();

return resultSet;

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Jun 21, 2019 9:33 PM UTC

Hi,

Communication between activities can only happen over text (/json serializations).

Instead of that code you could fork the transition ahead of the js activity, then invert the query to delete, i.e.:

sqlExec("delete from " + vars.tableName + " where sField1 <> '" + localVar + "'");

The outgoing transition will then have the desired result set.

Thanks,

-Jon

4 replies

RaulOcana
RaulOcanaAuthor
Level 3
Jun 21, 2019 10:11 PM UTC

Alright, thank you Jon!

Translate
Jonathon_wodnicki
New Participant
Jun 21, 2019 10:07 PM UTC

Just the temp results, or a copy of the temp results if you fork ahead of the activity- depends on what you're trying to do.

Translate
RaulOcana
RaulOcanaAuthor
Level 3
Jun 21, 2019 9:54 PM UTC

Hi Jon,

So you mean that I have to delete the records that doesn't match with the criteria from the "temp" result, right? That will only affect the temp results or it will delete it from the actual schema?

Thank you!

-Raúl

Translate
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Jun 21, 2019 9:33 PM UTC

Hi,

Communication between activities can only happen over text (/json serializations).

Instead of that code you could fork the transition ahead of the js activity, then invert the query to delete, i.e.:

sqlExec("delete from " + vars.tableName + " where sField1 <> '" + localVar + "'");

The outgoing transition will then have the desired result set.

Thanks,

-Jon

Translate