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
zgcharley_09zgcharley_09 

Streaming client can receive notification when a record is UPDATED but not created.

I write a simple streaming client. However, i found the client can't receive the notification when I UPDATED a existent record.

 

My client can receive the notification when i created a new record.

 

Does Streaming API doesn't push data to client when updating a record?

 

Thanks

zg

alextalext

Updating a record should trigger an event for the Streaming API.

 

Could you share your PushTopic query with us?

 

Cheers,

 

--alex

zgcharley_09zgcharley_09

The query like this: "SELECT Id,Name,BillingStreet,BillingCity FROM Account WHERE NAME LIKE 'PUSH%' "

alextalext

Will review this with our team and get feedback. --alex

Vinod MehraVinod Mehra

When you create a push topic with a WHERE clause, we track only the changes to the fields reference in the WHERE clause. For topics without WHERE clause events are generated upon every create and update.

 

> "SELECT Id,Name,BillingStreet,BillingCity FROM Account WHERE NAME LIKE 'PUSH%' "

 

In this case "name" field is the only field reference in the where clause. So updates will trigger an event only when:

 

1. name field changes

2. the new value matches the criteria: name like 'PUSH%'

 

In the upcoming release we are considering to generate events also when the fields referenced in the select list change. In your case: "Name", "BillingStreet" and "BillingCity". But this is still being discussed.

sdetweilsdetweil

wow.. for us this will be a problem. the fields I am identifying in my where clause will NEVER change.. (they do match the records my user wants selected to display in the view list, so I would hope the two match).

 

I want notifications of ALL changes (inserts/updates) for the records I identified (from), that meet the where clause conditions.

you could do your way or mine with an attribute on the pushtopic definition..

 

as you have it defined, this will be nearly impossible to use.

 

ouch

 

Sam

Vinod MehraVinod Mehra

Suppose PushTopic.query is:

 

select f1, f2, f3 from XYZ where f4 = ... and f5 = ...

 

and we generate events when any of f1, f2, f3, f4, f5 change (meaning we watch both fields in the select list as well as where clause) and the new values meet the where clause, will that solve your usecase? Asking because this change is being considered for the next release.

 

--Vinod.

sdetweilsdetweil

not really sure.. consider a normal view list.  what is displayed  may have NO bearing on what fields change..

 

 so for example I want to see case number, account, contact, status, product, owner, and some other fields

 

status = not(closed) and region = asia_pacific and owner in (bob,sue, unassigned) and

(family='CA Products' and (product='Distributed Database Mgmt' and (component not in ('AIM FOR MICROSOFT SQL SERVER','AIM FOR ORACLE','AIM FOR ORACLE'))) or (product='Software Change Manager - PPM')) or (family='Emerging Businesses' and (product in ('ecoGovernance', 'ecoGovernance On Demand', 'ecoMeter')))

 

I have no clue IF any of the fields the user selected to view are in fact the fields that might be changed.  the customer might have added a comment,

nothing else changed.. I can't use last changed in the where.. so I would have to put it in the select list..  and somehow not show it..



what I was 'expecting' was that the pushtopic would select the subset of records that satisfied the where clause that changed or were added, 

and return the defined pushtopic fields on the notification for those records.

 

'select id from case'  means tell me about ALL cases that change or are added (tell me which is which)

select id from case where product ='xyz' means tell me about all cases that changed where the product='xyz', but (unknown) other fields changed, product did not.

 

each of my users has their own personal soql stmt select list.

 

sam

VM_SFDCVM_SFDC

> I have no clue IF any of the fields the user selected to view are in fact the fields that might be changed.  the customer might have added a comment, nothing else changed.. I can't use last changed in the where.. so I would have to put it in the select list..  and somehow not show it..

 

Please help me understand this. If only "comment" field changed and that is not even in the list view the user is on and it is not a part of WHERE or SELECT list, why will that event be interesting to the end user? It is going to get the same data back that is in the list view currently.





sdetweilsdetweil

because the in/out status of the issue changed.

 

today in our hand built UI, we change the color of the row for that issue, which didn't move position in the list view

because the customer replied last. our folks like that feature..

 

Sam

VM_SFDCVM_SFDC

I am assuming "in/out" status will be a field on the entity. Why don't you add it to the select/filter list?

sdetweilsdetweil

its calculated. but wouldn't change prior to the display refresh.

 

so, i'm back to my original understanding

 

the pushtopic provides a soql select that defines  a set of records of type X.

if any record in that set changes, for any reason, then the pushtopic should fire a notification to all listeners whose specific where clause is satisfied by this changed record list.

the specified soql may not include reference to the field which caused the change record trigger to fire

 

in our design using Case, we cannot use the std Notes & Attachments objects.. so our custom ones have triggers that change a custom

hidden field on their parent Case. The value of this field does not satisfy any particular soql where subclause, but should cause the pushtopic event to fire for all topics where the set includes this case record. ie, I should be able to remove the logic in my Case object trigger that deals with notifications and use streaming, eliminate my polling logic, replace it with the pushtopic notification logic, provide better change notification responsiveness to my users, and reduce the load on the SF system.

 

mapping the where clause sets to the changed records is the fun part.

in my design, i would have 900 pushtopics registered, with approx 750 unique soql (where) stmts (I am guessing at the concurrency of clauses)

when a topic is created. I wouldclaculated and assign a position of the where clause in a list of where clauses, from least complex (all) to most complex. (invention needed here). the returned fieldlist for this topic would be saved as well.. (some would share the same where clause, but not the fieldlist)

 

i would create a trigger for the data type specified in the pushtopic. after insert, after update.

 

the triggers job is to run thru the list of listeners and somehow match the where clause to the modified records (invention here), building a notification list of listeners (total 900), and put their returned variables on their notification entry (all in memory), when the listener list is complete, then fire something (future) to send the notifications.

 

maybe u do this already, but use the before and after trigger field list to decide on the where clause satisfaction.

 

Sam