Ad

MetadataAPI: Could Not Resolve List View Column: First_Name FIELD_INTEGRITY_EXCEPTION

- 1 answer

I am using Salesforce metadata api to create a contacts list view with one filter. The filter should contain First Name.

metadata = [{
      fullName: 'Contact.listViewName1',
      label: listViewName1,
      filterScope: 'Everything',
      filters: [{
        filter: "First_Name",
        operation: "contains",
        value: 'AUTO_'
      }]
    }];

I tried using 'filter' instead of 'field' and I get the following:

element {http://soap.sforce.com/2006/04/metadata}filter invalid at this location in type ListViewFilter

Ad

Answer

For standard field use FirstName, no underscore. If you have made a custom field - it'll end with __c so probably First_Name__c.

List of standard fields: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm

For view including your custom fields you'll need to go to Setup -> Object Manager -> Contact -> fields and relationships

I don't know what you're using (jsforce? Tooling API?), what's normally being deployed using Metadata API should look like this. You'll need to do the XML - JSON translation yourself

<listViews>
    <fullName>listViewName1</fullName>
    <columns>FULL_NAME</columns>
    <columns>ACCOUNT.NAME</columns>
    <columns>CONTACT.PHONE1</columns>
    <columns>CONTACT.EMAIL</columns>
    <columns>CONTACT.TITLE</columns>
    <columns>CORE.USERS.ALIAS</columns>
    <filterScope>Everything</filterScope>
    <filters>
        <field>CONTACT.FIRST_NAME</field>
        <operation>contains</operation>
        <value>AUTO_</value>
    </filters>
    <label>listViewName1</label>
</listViews>

Documentation: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listview.htm

Ad
source: stackoverflow.com
Ad