• Resolved Insight Dezign

    (@insightdezign)


    Again I must profess my love for this plugin!

    I do need a little more help though. I have a date field in salesforce that I’m mapping to custom meta field. When it syncs it comes over as a string. I would like to filter it before it writes to the custom field so it converts to a unix timestamp. That way I can sort by the meta data and convert it back after. Is there a function to filter a field so I can write a function to convert it?

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

    (@jonathanstegall)

    @insightdezign yes, there is a hook for this. I haven’t done this particular thing, but I think this is one way you might do it.

    
    add_filter( 'object_sync_for_salesforce_pull_params_modify', 'change_date_field_type', 10, 6 );
    function change_date_field_type( $params, $mapping, $object, $sf_sync_trigger, $use_soap, $is_new ) {
    	$params['your_date_field']['value'] = strtotime( $params['your_date_field']['value'] );
    	return $params;
    }
    
    Thread Starter Insight Dezign

    (@insightdezign)

    Perfect! Exactly what I was looking for. Hopefully it’s helpful to someone else in the future. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter Date field’ is closed to new replies.