Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Aldo1
Contributor
Contributor

tSalesforceInput and COUNT

Gurus,

I have a requirement to query a Salesforce object and get a row count without actually retrieving all the rows. In SOQL I can execute the query: select COUNT() from Account

...and it will return the number of records. I can enter this same query into my tSalesforce component and it will execute without throwing an error.... so it doesn't seem to have a problem running the query itself. But I can't figure out how to access the value it returns.

Since it doesn't return with a field name, I can't specify the field in the Schema. I tried specifying a field to count... e.g.

Select COUNT(Id) from Account

And then creating a schema with a single line: Id --> Integer

No good. Id returns null.. I played around with using "COUNT" as the Column name, changing to a String, etc. Nothing works so far. I know that I can always select only the Id, let it fetch every row and then look at the tSalesforceInput_1_NB_LINE value for my row count. But I was trying to avoid the long run-time and the network traffic that occurs when retrieving every record. Any ideas what I might put in that schema?

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello,

Please try the below query :

Select COUNT(Id) total from Account

in the schema of tSalesforceInput, setup the total as the column name as the below

0695b00000Uxur4AAB.png

View solution in original post

2 Replies
Anonymous
Not applicable

Hello,

Please try the below query :

Select COUNT(Id) total from Account

in the schema of tSalesforceInput, setup the total as the column name as the below

0695b00000Uxur4AAB.png

Aldo1
Contributor
Contributor
Author

Works great. Thank you!

 

I had tried using an alias in a SOQL query in the past and it failed. I discovered back then that Salesforce rejects aliases unless they are used on aggregate functions / "group by" SOQL queries. It must have slipped my mind.