6

I have successfully created a PushTopic through the PHP Force Workbench running locally. Then, I monitor the results under the 'Streaming Push Topics' feature in Workbench.

Here is the PushTopic:

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'ContactUpdates';
pushTopic.Query = 'SELECT LastName, FirstName, MailingStreet, MailingCity, MailingState, MailingPostalCode, Id FROM Contact';
pushTopic.ApiVersion = 37.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

Notice I am explicitly declaring NotifyForOperationUpdate. When I monitor this stream, I get notifications for the account creations, but not for the account updates. Specifically, I was updating the LastName and FirstName fields.

When I create a new PushTopic and specificy NotifyForFields as 'All', I am able to see updates.

I can certainly use 'All' with the significant downside of getting updates that do not matter to the application.

Question 1: Why does updating FirstName and LastName not work for 'Referenced' fields, but does work for 'All', since the query SELECT clause includes FirstName and LastName?

NOTE: this is not a duplicate of Streaming API : not getting updates for some standard fields as I am specifying explicit Apex options and for a different API version. However, the answer may be the same for both (which could be as simple as, "it is a bug in SalesForce Streaming API").

  • 3
    Nice first question! – Adrian Larson Feb 9 '17 at 18:20
  • Thanks @AdrianLarson! I've worked with StackOverflow a fair amount, so trying to follow same procedures. Nice to see the community is friendlier on this side ;) – ryanm Feb 9 '17 at 18:28
2

You have to add in your query the "Name" field :

Your query would look like this : 'SELECT Name, LastName, FirstName, MailingStreet, MailingCity, MailingState, MailingPostalCode, Id FROM Contact'

Then when you update the lastname or firstname it will send a notification.

salesforce documentation : https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/pushtopic_queries_compound_fields.htm

  • @ryanm you should accept this answer. The official docs referred to clearly states why your update is not firing and how to fix the issue. – JannieT Oct 1 '18 at 7:54
0
  1. Try adding a where clause (it can be something that is always expected to be true such as created date after 1900)
  2. Change NotifyForFields to Select
  • Thanks for the ideas! I am no longer actively working on this project, so it may take some time for me to vet these. Meanwhile, if anyone in the community can test / vet these and they work, please let me know. While #1 may work, it is a workaround. I'm OK with workarounds, so long as they are long-term (won't get munged by an API minor version update) and they fix the glitch. Seems the glitch is on SalesForce's side for this problem. – ryanm Mar 10 '17 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.