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
Gabe LevyGabe Levy 

pushtopic

Hello, 

I'm currently following the salesforce trailhead, and one of the items it says for me to do is create a PushTopic 
https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/code_sample_java_create_pushtopic.htm

I put in the code it lists into the developer console,
PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'InvoiceStatementUpdates';
pushTopic.Query = 'SELECT Id, Name, Status__c, Description__c FROM Invoice_Statement__c';
pushTopic.ApiVersion = 48.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

but I get Line: 10, Column: 1
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, Invalid ApiVersion: [ApiVersion]

Any advise?
ProlayProlay
I used ApiVersion 38 and it worked.
 
PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'aa';
pushTopic.Query = 'SELECT Id, Name, StageName,CloseDate FROM opportunity';
pushTopic.ApiVersion = 38.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

 
ProlayProlay
I think the issue is the pushTopic.ApiVersion. Try with 45.0. It worked.
ProlayProlay
Spring'20 ApiVersion is 47.
 
Purva K 4Purva K 4

Sorry for posting question here but I need help!!!

I am using Streaming API and due to the character limit of SOQL, I am unable to write one SOQL for one object (as this object has numerous fields) .
Can I write two SOQL for same object and configure to same pushTopic?
If yes, please can you give an example.