Fork me on GitHub

Has anyone had the [dis]pleasure of syncing app data into SalesForce via the SF API?


I only know someone who has and they spoke about it like someone would speak about a rough patch in their marriage or the death of a relative


Yeah I have to do this pretty often at work


Any tips on the sanest way to do this? Our app uses Postgres, but the business team wants a sub-set of the data to be synced over to SF which has a matching schema of objects (give or take). At this point it seems like I’m trying to create an ad-hoc replication protocol between PG -> SF, that in turn has to be able to deal with network outages and the like, and later able to catch up with syncing. That in turn seems like a legit difficult problem in distributed computing, but no one else seems to appreciate that fact.


I’m also under the impression that all FK relationships need to be mapped to SF FKs, because SF can’t be bothered to just use the existing PG FKs…


Well, what’s your use case exactly? Storing data in two places seems really terrible. We usually opt to store data in Salesforce or Postgres (but usually not in both places). If our customer reps have the need to access data stored in Postgres, we expose an endpoint to fetch data then our SF devs will build out pages to display that data in Salesforce.


I’m not too sure on the details of how the SF devs do it, but I believe there’s a way to build custom apps within Salesforce to fetch data from a service or DB without having to actually store it in Salesforce


Im 100% in agreement that storing data in 2 places is terrible, yet that’s exactly the requirement. I’ve tried to get the team to use Metabase to pull reports directly from PG but the team is dead set on using SF. We also have no SF devs in house.


I think a big driver is the ability to create automated workflows to take action based on the data that is synced over into SF objects.


Oh shoot, well seems like you can’t get away from that then. As far as network outages, retries, etc. you might have luck using a serverless solution like SQS-Lambda


We have some lambdas that create objects in Salesforce when certain events happen. The SF api is easy enough to work with and with SQS-Lambda it’s easy to configure your retry behavior.


Our app also triggers object creation directly, when a user performs an action we sometimes create things in Salesforce directly from our backend service. Not sure if that helps. It sounds to me like backfilling and making sure data is perfectly synchronized will be difficult.


We also create automated workflows when a user triggers certain events in the app that require manual intervention from our customer service reps.


The Salesforce API is really not that difficult to work with


Yeah the API is easy enough, and you are right, the backfilling and ensuring consistency is the thing I’m most worried about. The single object create/update is too slow to backfill, so I also need to use the bulk insert api


The thing that literally kept me up last night was figuring out the existing syncing was triggering in a separate process before the PG DB transaction committed

😱 4

And also there were concurrent worker processes potentially syncing the same object


Between those the facts, it was possible for an older copy of an object to overwrite a newer version in SF, thus bringing SF subtly out of sync with PG


I miss drinking


A very particular question, mostly about Linux and partially about Java/Clojure. Is it possible to create a GraalVM-compiled executable from Clojure code that has the setuid bit and: 1. Uses to run a third-party program 2. Runs that program in a way that makes it seem like that program itself has the setuid bit I just tried and it doesn't seem to work that way by default, probably a security measure that I'm not aware of. But is it possible to somehow explicitly tell the OS that it's OK in this case?


Or maybe I have to somehow call setuid from Clojure?


in terms of running another program, that sounds like dynamic setuid which sounds no fun


I have come to a conclusion that nothing about setuid sounds fun. :) It appears that even without running other programs, I cannot use setuid on a Graal-VM-compiled binary that easily.


Really? That surprises me


The only "restrictions" are on scripts


And that's because bash executes it, and doesn't have setuid itself


I have to call the setuid C function from a program that has that bit to make sure that I'm indeed acting on behalf of the other UID.


So seems like I have to use JNI.