• Resolved Insight Dezign

    (@insightdezign)


    As I’m using this to sync Account with a certain record type to create a WordPress custom post, I’m finding that I end up syncing accounts that I don’t want because they share the same record type. We have another custom field in Salesforce to filter then when we run reports. It would be great if there could be an option to choose a field as a filter and enter the default value that should be checked for before sync.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    To your specific question, if I understand you correctly, the plugin does allow for Accounts (and other objects in Salesforce that have a RecordType field) to only sync records that have the desired type. Here’s a screenshot of how that works.

    To be more general, you can certainly prevent a push or pull based on a field’s value using a developer hook, but I don’t think doing it visually is likely to be a feature in the plugin quickly, as you say.

    We have some degree of documentation about all of the developer hooks – though to be clear, we don’t provide support for using them – at https://github.com/MinnPost/object-sync-for-salesforce/blob/master/docs/all-developer-hooks.md.

    But if you’re trying to skip Salesforce records based on a certain field that is not the built-in RecordType field, you might be able to do it like this.

    add_filter( 'object_sync_for_salesforce_pull_object_allowed', 'check_account', 10, 5 );
    function check_account( $pull_allowed, $object_type, $object, $sf_sync_trigger, $mapping ) {
    	if ( $object_type === 'Account' && $object['field_to_check'] === 'abcdef' ) {
    		$pull_allowed = false;
    	}
    	return $pull_allowed;
    }
    Thread Starter Insight Dezign

    (@insightdezign)

    Thank you. This will work just fine.

    Questions though. Does $object_type and $object take the api name or the visual name?

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    The plugin only stores API names for objects and fields.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    I’m going to close this topic for now since code will achieve what you need, although I’ve added your suggestion to GitHub. Certainly I don’t have any estimation for when or if that might happen in the plugin (it won’t be soon) but it’s definitely worth consideration.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Suggestion for Filter option’ is closed to new replies.