Question

Query Salesforce and Postgresql

  • 12 February 2023
  • 3 replies
  • 71 views

Userlevel 1
Badge +1

Hello,

First timer here.

I am currently evaluating Zapier to see if will help streamline a process I go through frequently.  The tool seems fairly straightforward and I have at least been able to make the connections to the systems I am using.  I would like to know if the following use case is possible:

Automate (probably weekly) checking Salesforce to see which customer’s contracts have expired.  This would be accomplished by checking the contract expiration date field and listing all customers where the expiration date is less than today.  Next, I would like to somehow pass that customer(s) (I’ll probably create a customer id field in Salesforce) to a Postgresql query to check a certain date field to see if they are still using the solution after expiration.

I’m not looking for step-by-step, but rather if the above can be accomplished and if so, how can I pass parameters (e.g. customer id) found in Salesforce to the SQL query?

Open to other solutions as well (e.g. writing results to Google Sheets if easier).

 

Thank you!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

Hi @PatrickD 

Good question.

Most Zap actions work on a per record basis, meaning if you were to search Salesforce and there are matches, then only 1 match will be returned as there could be thousands of matching records in theory.

I believe the Salesforce Find Record(s) still only returns 1 record.

 

 

Userlevel 1
Badge +1

Thank you for the heads-up, Troy.  Although the record set would typically be small, it certainly would be at times more than one record.  I’ll have to brainstorm for an alternative option.

 

Thanks.

Userlevel 7
Badge +12

Hi @PatrickD, welcome to the Community!

This is somewhat possible but would you’d need to add a field in Salesforce. 

I checked the Salesforce Find Record(s) and it does return multiple records if more than one is found. What wouldn’t be possible is to use that action to find accounts where the contract has expired, that type of search needs the Find Record by Query, which doesn’t support finding multiple records. 

If it were me, I would create a Boolean field in Salesforce that looks at the contract expiry date and marks it as in contract with a True or False. You could use that to find multiple records. 

 

To schedule a Zap to check regularly you can use Schedule by Zapier, which would be your Zap trigger in this case. 

 

To add each record to SQL you can use Looping by Zapier, which will loop through each line item and add it to your SQL database.

 

That’s quite a complex workflow so don’t hesitate to ask if you have any questions!