Skip to content

TransformHasResult Operator

Martin Danielsson edited this page Oct 23, 2015 · 1 revision

The TransformHasResult operator returns true if a called source transform (see Config File Documentation, section SourceTransform) returns any results. This is especially useful if the transform is a query which may return zero to an arbitrary number of results and you only want to generate output if there is actual output.

The operator is normally used in the SourceFilters section.

Example:

<Transformation>
  <Source config="delim=';'">file://account_ids.csv</Source>
  <SourceTransform>
    <Transform config="sfdc_config.xml">soql.net://select Id, Name, Revenue__c from Opportunity where AccountId='%account'</Transform>
    <Parameters>
      <Parameter name="account">$AccountId</Parameter>
    </Parameters>
  </SourceTransform>
  <Target config="delim=';'">file://opportunities_with_revenue.csv</Target>

  <SourceFilters>
    <SourceFilter>TransformHasResult()</SourceFilter>
  </SourceFilters>

  <Fields>
    <Field name="AccountId">$AccountId</Field>
    <Field name="Id">$Id</Field>
    <Field name="Name">$Name</Field>
    <Field name="Revenue">$Revenue__c</Field>
  </Field>
</Transformation>

In this example, for a CSV of Account IDs, all opportunities are output. Without the TransformHasResul() filter, accounts without any opportunities would be output as a line in the CSV only containing the Account ID and the rest as empty fields:

AccountId;Id;Name;Revenue
0009320909032afddCDA;;;

Use the TransformHasResult operator to filter out these lines.

Clone this wiki locally