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
rajeev bhardwajrajeev bhardwaj 

PushTopic Creation Issue

Hi All,

To get updates from salesforce Account, Contact and AccountContacRole objets into my local database. I have create pushTopic for Account and Contact object and recieving update messages using JAVA streaming client successfully. But when I was creating pushTopic for AccountContactRole object using following query in developer console. 

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'ACRoleTableStreaming';
pushTopic.Query = 'SELECT AccountId,ContactId,IsDeleted,IsPrimary,Role FROM AccountContactRole';
pushTopic.ApiVersion = 30.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

I am getting following Error message.

12:59:29:065 EXCEPTION_THROWN [10]|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, 'AccountContactRole' is not supported: [Query]

FYI I have also tries creating above pushTopic using https://workbench.developerforce.com. Still gote same Error.

Can anyone please tell me how can I ceate pushTopic for AccountContaactRole object or how can I get real time updates from this object into my local databse using salesforce Streaming Client or any other method ?

Best Answer chosen by rajeev bhardwaj
Sfdc CloudSfdc Cloud
Hi Rajeev,
Relationship query are not supported with push topic.You cannot pull all AccountContactRole related to Account.
http://www.salesforce.com/us/developer/docs/api_streaming/api_streaming.pdf
Have a look into this guide under Unsupported Push Topic .
• Relationships aren’t supported, but you can reference an ID:
◊ Example query: SELECT Id, Contact.Account.Name FROM Contact
◊ Error message: INVALID_FIELD, relationships are not supported


If this helps you out mark it as best ans to help other

All Answers

Sfdc CloudSfdc Cloud
Hi Rajeev,
Relationship query are not supported with push topic.You cannot pull all AccountContactRole related to Account.
http://www.salesforce.com/us/developer/docs/api_streaming/api_streaming.pdf
Have a look into this guide under Unsupported Push Topic .
• Relationships aren’t supported, but you can reference an ID:
◊ Example query: SELECT Id, Contact.Account.Name FROM Contact
◊ Error message: INVALID_FIELD, relationships are not supported


If this helps you out mark it as best ans to help other
This was selected as the best answer
buggs sfdcbuggs sfdc

HI Rajeev,

Even am working a similar requiment can you please help me out how to start it.

How to create a Push topic for streaming API on Account object for all DML operations(insert,update,delete,undelete).And i wanted to provide this API to ETL team.how can i start doing it,i just started my research by(https://developer.salesforce.com/page/Getting_Started_with_the_Force.com_Streaming_API) which gives basic info about streaming API. can anyone help me out in giving some sample code for all other operations and at the same time how can we test this?here i need to write any Apex class.Can you check the below code,Am a newbie please help me to fix it.

Thanks In Advance
@RestResource(urlMapping='/StreamingAPI/*')
global with sharing class StreamingController {
 @Httppost
 Global static Void MystreamingAccount(){
  
  PushTopic pushTopic = new PushTopic();
    pushTopic.Name = 'AccountUpdates';
    pushTopic.Query = 'SELECT Id, Name FROM Account';
    pushTopic.ApiVersion = 37.0;
    pushTopic.NotifyForOperationCreate = true;
    pushTopic.NotifyForOperationUpdate = true;
    pushTopic.NotifyForOperationUndelete = true;
    pushTopic.NotifyForOperationDelete = true;
    pushTopic.NotifyForFields = 'Referenced';
    insert pushTopic;
    
  PushTopic pushTopiccon = new PushTopic();
    pushTopiccon.Name = 'ContactUpdates';
    pushTopiccon.Query = 'SELECT Id,LastName FROM Contact';
    pushTopiccon.ApiVersion = 37.0;
    pushTopiccon.NotifyForOperationCreate = true;
    pushTopiccon.NotifyForOperationUpdate = true;
    pushTopiccon.NotifyForOperationUndelete = true;
    pushTopiccon.NotifyForOperationDelete = true;
    pushTopiccon.NotifyForFields = 'Referenced';
    insert pushTopiccon;
    
  PushTopic pushTopicopp = new PushTopic();
    pushTopicopp.Name = 'OpportunityUpdates';
    pushTopicopp.Query = 'SELECT Id,Name,StageName,Closedate FROM Contact';
    pushTopicopp.ApiVersion = 37.0;
    pushTopicopp.NotifyForOperationCreate = true;
    pushTopicopp.NotifyForOperationUpdate = true;
    pushTopicopp.NotifyForOperationUndelete = true;
    pushTopicopp.NotifyForOperationDelete = true;
    pushTopicopp.NotifyForFields = 'Referenced';
    insert pushTopicopp;
 }
 

 }