0

I am trying to filter a data extension to only return certain rows via an SSJS automation.

It works fine if I set the SimpleOperator to "equals" and the Value to a static value.

What I really want to be able to do is filter on a number of values like this:

 var dataextensionexternalkey = 'externalkey';
 var dataExtension = DataExtension.Init(dataextensionexternalkey);
var filter = {Property:"LANGUAGE_CODE",SimpleOperator:"IN", Value:'"DA", "DE", "EN", "ES", "FR", "IT", "NL", "NO", "PL", "PT", "FI", "SV", "TR", "ZH"'};
var dataExtensionRows = dataExtension.Rows.Retrieve(filter);
Write('<hr>number of rows in filtered dataextension: ' + dataExtensionRows.length() + '<hr>');

But no rows are retrieved, it says: number of rows in filtered dataextension: 0

What am I doing wrong in the filter definition.

It works fine when I filter like this:

var filter = {Property:"LANGUAGE_CODE",SimpleOperator:"equals", Value:'EN'};

2 Answers 2

1

I found out how to make it work. You have to make an array of your IN values:

var availLanguagesArray = ["DA", "DE", "EN", "ES", "FR", "IT", "NL", "NO", "PL", "PT", "FI", "SV", "TR", "ZH"];
var filter = {Property:'LANGUAGE_CODE',SimpleOperator:'IN', Value: availLanguagesArray};

var sourceRows = sourceData.Rows.Retrieve(filter);

And Bob's your uncle...

0

In addition to the other answer:

If you are reading this and want to do it via SOAP instead of Rows.Retrieve (or perform a SOAP Call inside of your SSJS...), then it works differently - as I found out through trial and error:

here is an example of a retrieveRequest on Send Object:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>
     <fueloauth>YOURTOKENHERE</fueloauth>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
     <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
       <RetrieveRequest>
          <ObjectType>Send</ObjectType>
          <Properties>ID</Properties>
          <Properties>Client.ID</Properties>
          <Properties>Email.ID</Properties>
          <Filter xsi:type="SimpleFilterPart">
             <Property>ID</Property>
             <SimpleOperator>IN</SimpleOperator>
             <Value>xxxx</Value>
             <Value>yyyyy</Value>
          </Filter>
       </RetrieveRequest>
    </RetrieveRequestMsg>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .