如何为SOQL对象提取所有可用的查询字段?

时间:2018-05-07 13:38:39

标签: salesforce

所以,我看到Stackoverflow比实际的Salesforce社区更具响应性,我正在从here重新发布我的问题:

如何为SOQL对象提取所有可用查询字段的列表?我准备好了我的DataLoader脚本,但我需要一种方法来提取特定SOQL数据对象的所有查询字段,并将它们提供到DataLoader中的process-conf.xml文件中,以将所有这些字段的值拉到一个单独的位置。我已经设置了DataLoader值,但我需要一种方法来获取所有可用的查询字段,因为它们会继续更改。 ANT迁移工具似乎无法自行提取查询字段。

ANT工具配置:

# build.properties  
# Specify the login credentials for the desired Salesforce organization
sf.username = <test user acct>
sf.password = <password>
#sf.sessionId = <Insert your Salesforce session id here.  Use this or username/password above.  Cannot use both>
#sf.pkgName = <Insert comma separated package names to be retrieved>
#sf.zipFile = <Insert path of the zipfile to be retrieved>
#sf.metadataType = <Insert metadata type name for which listMetadata or bulkRetrieve operations are to be performed>   
sf.serverurl = https://na3.salesforce.com
sf.maxPoll = 20
# If your network requires an HTTP proxy, see http://ant.apache.org/manual/proxy.html for configuration.
#
logType=Detail

的build.xml

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">

    <property file="build.properties"/>
    <property environment="env"/>

    <!-- Setting default value for username, password and session id properties to empty string 
         so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
         will be treated literally.
    -->
    <condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
    <condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
    <condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <classpath>
            <pathelement location="ant-salesforce.jar" />           
        </classpath>
    </taskdef>

    <!-- See what happens here -->
    <target name="retrieveSOQL">
      <sf:retrieve 
          username="${sf.username}" 
          password="${sf.password}" 
          sessionId="${sf.sessionId}"
          serverurl="${sf.serverurl}" 
          retrieveTarget="output" 
          unpackaged="package.xml"/>
    </target>
</project>

package.xml中

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Account</members>
        <members>Opportunity</members>
        <members>Lead</members>
        <members>Event</members>
        <members>Project__c</members>
        <name>CustomObject</name>
    </types>
    <version>41.0</version>
</Package>

过程-conf.xml中

<beans>
    <bean id="AccountExtract"
          class="com.salesforce.dataloader.process.ProcessRunner"
          singleton="false">
      <description>csvAccountExtract job</description>
        <property name="name" value="csvAccountExtract"/>
        <property name="configOverrideMap">
            <map>
                <entry key="sfdc.debugMessages" value="false"/>
                <entry key="sfdc.debugMessagesFile" value="C:\Users\user\Desktop\salesforce_backup\sfdcSoapTrace.log"/>
                <entry key="sfdc.endpoint" value="https://na3.salesforce.com"/>
                <entry key="sfdc.username" value="<username>"/>
                <!-- password below has been encrypted using key file, therefore it will not work without the key setting: process.encryptionKeyFile
                the password is not a valid encrypted value, please generate the real value using encrypt.bat utility -->
                <entry key="sfdc.password" value="<password>"/>
                <entry key="process.encryptionKeyFile" value="key.txt"/>
                <entry key="sfdc.timeoutSecs" value="600"/>
                <entry key="sfdc.loadBatchSize" value="200"/>
                <entry key="sfdc.entity" value="Account"/>
                <entry key="sfdc.extractionRequestSize" value="500"/>
                <entry key="sfdc.extractionSOQL" value="Select Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet FROM Account"/>
                <entry key="process.operation" value="extract"/>
                <entry key="dataAccess.type" value="csvWrite"/>
                <entry key="dataAccess.name" value="C:\Users\user\Desktop\account.csv"/>
            </map>
        </property>
    </bean>
...
</beans>

0 个答案:

没有答案