function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jason Harris 1Jason Harris 1 

How should a Streaming API PushTopic be created so that updates to individual fields in the query result in a notification

I have created a PushTopic as below:
{
    "Name" : "contact_with_notify",
    "Query" : "SELECT Id, LastName, FirstName, Phone from Contact",
    "ApiVersion" : 32.0,
    "NotifyForOperationCreate" : true,
    "NotifyForOperationUpdate" : true,
    "NotifyForOperationUndelete" : true,
    "NotifyForOperationDelete" : true,
    "NotifyForFields" : "SELECT"
}

but no matter what value I set for 'NotifyForFields', subscriptions to this topic only receive notifications when every field in the topic query is changed. How do I modify query so that a notification is sent when ONE field in query changes? Or do I need a topic per field?
Jason Harris 1Jason Harris 1
Actually, it looks like "NotifyForFields" : "ALL" does it BUT this then notifies subscriber for field changes NOT in query select or where!
BalajiRanganathanBalajiRanganathan

you should not use 'All' as it will cause the notification to trigger for other field changes that are not in select clause. you can try not setting the "NotifyForFields" itself, which will default it to 'Referenced', or you can try using case sensitive 'Select'. I don't think you need to create topic per field
Jason Harris 1Jason Harris 1
Whether I set it to Referenced or Select (or don’t include it), the only way I get a notification is if I change every field in a Contact. Changing just one field in the query only creates a notification if ‘NotifyForFields’ is set to 'All' which, as you say, results in notifications when any fields in Contact are changed, not just the ones in the query. 
ezdhanhussainezdhanhussain
One way to do is confine your Query to limited fields and Use  "NotifyForFields" : "Referenced". But single field changes are not possible. I have raised an idea for this. support your thoughts..

https://success.salesforce.com/ideaView?id=08730000000DgpVAAS (https://success.salesforce.com/ideaView?id=08730000000DgpVAAS" target="_blank)