0

I have the soql extract through ANT which works fine. However when I used "<" symbol. It is throwing error

The value of attribute "soql" associated with an element type "export_IndividualEmail" must not contain the '<' character.

It mentioned in following url https://stackoverflow.com/questions/30202080/ant-i-o-redirection-must-not-contain-the-character to escape < with & lt;

However it is not working with soql where clause. What is the solution to use < in soql

   <?xml version="1.0" encoding="UTF-8"?>
 <project name="Export" default="all">
<property file="build.properties"/>
<property environment="env"/>
<tstamp>
    <format property="todayDate" pattern="MM-dd-yyyy_HH-mm-ss" />
    <format property="todayDate_only" pattern="MM-dd-yyyy" />
</tstamp>
<!-- subtract 2 days from Today -->
<tstamp>
    <format property="twoDaysAgo" pattern="yyyy-MM-dd" offset="-2"/>
</tstamp>

<macrodef name="export_IndividualEmail">
    <attribute name="file"/>
    <attribute name="object"/>
    <attribute name="soql"/>
    <attribute name="userName"/>
    <attribute name="password"/>
    <attribute name="serverURL"/>
    <attribute name="batchSize"/>
    <!-- <attribute name="limit"/> -->

    <sequential>
        <echo message="Exporting @{object}"/>
        <mkdir dir="exports/${todayDate_only}"/>
        <mkdir dir="logs/${todayDate_only}"/>
      <!--      <input
            message="Enter Year, example: 2014"
            addproperty="date.year"
        />
    <input
            message="Enter Month in number"
            validargs="1,2,3,4,5,6,7,8,9,10,11,12"
            addproperty="date.month"
        />
        <input
            message="Enter Day"
            addproperty="date.day"
        /> -->
        <copy file="config/template-process-conf.xml" tofile="config/process-conf.xml" overwrite="true" failonerror="true"/>
        <replace file="config/process-conf.xml">
            <replacefilter token="_object_" value="@{object}"/>
            <replacefilter token="_soql_" value="@{soql} LAST_MONTH"/>
            <replacefilter token="_file_" value="exports/${todayDate_only}/@{file}.csv"/>
            <replacefilter token="_serverURL_" value="@{serverURL}"/>
            <replacefilter token="_userName_" value="@{username}"/>
            <replacefilter token="_password_" value="@{password}"/>
            <replacefilter token="_batchSize_" value="@{batchSize}"/>
            <replacefilter token="_logFile_" value="logs/${todayDate_only}/@{file}_log.csv"/>
        </replace>
        <java classname="com.salesforce.dataloader.process.ProcessRunner" classpath="C:\Program Files (x86)\salesforce.com\Data Loader\dataloader-44.0.0-uber.jar" failonerror="true">
            <sysproperty key="salesforce.config.dir" value="config"/>
            <arg line="process.name=@{object}"/>
        </java>
    </sequential>
</macrodef>

<target name="all">
    <export_IndividualEmail
        file="IndividualEmailResultsMonthly_backup-${todayDate}"
        object="et4ae5__IndividualEmailResult__c"
        soql="SELECT CreatedById,CreatedDate,et4ae5__CampaignMemberId__c,et4ae5__Clicked__c,et4ae5__Contact_ID__c,et4ae5__Contact__c,Name,OwnerId,Sent_in_Last_365_Days__c,SystemModstamp FROM et4ae5__IndividualEmailResult__c WHERE et4ae5__DateSent__c  = LAST_N_MONTHS:4 AND et4ae5__DateSent__c  < LAST_N_MONTHS:3  "
        userName="${sf.prod.profileName.username}"
        password="${sf.prod.profileName.password}"
        serverURL="${sf.serverurl}"
        batchSize="200"
         /> 
</target>
4
  • Please provide a sample build.xml file so we can troubleshoot this?
    – sfdcfox
    Jul 9, 2020 at 19:41
  • @sfdcfox, I have added the build.xml file, It is failing on soql where condition when < symbol is used WHERE et4ae5__DateSent__c = LAST_N_MONTHS:4 AND et4ae5__DateSent__c < LAST_N_MONTHS:3
    – DevLearner
    Jul 13, 2020 at 15:43
  • @sfdcfox, Can you please able to help with the answer ?
    – DevLearner
    Jul 15, 2020 at 21:41
  • I found answer for this. If you need to use < in ANT, we can go for javascript as given below. Hope this helps someone <script language="javascript"> <![CDATA[ project.setProperty("Lessthan","&lt;"); ]]> </script> <replacefilter token="soql" value="@{soql} ${Lessthan} LAST_N_MONTHS:2"/>
    – DevLearner
    Jul 17, 2020 at 20:26

1 Answer 1

1

I found answer for this. If you need to use < in ANT, we can go for javascript as given below. Hope this helps someone

       <script language="javascript">
    <![CDATA[
    project.setProperty("Lessthan","&lt;");
    ]]>
    </script>   
        .
        .
        .
       <replacefilter token="_soql_" value="@{soql} ${Lessthan} LAST_N_MONTHS:2"/>

You must log in to answer this question.

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