Authorized Services and Salesforce
# help-with-umbraco
s
I need some help with connecting Salesforce and my Umbraco (v13) frontend. The idea is to display product information from SF on public pages. I am trying to use the Umb Authorized Services package to handle the connection to the SF connected app. I can get the initial connection to work properly but cannot get it to persist. Does anyone have experience doing something similar that would be willing to share some insights into both SF and Umb configs?
p
I've not used it yet in newer versions of Umbraco but I have a v7 site that I manage which uses the SalesForce API to synchronise content into Umbraco and it seems to be too slow to be using it to serve content directly on the site. I am in the process of migrating the site to v12 or beyond and considering a different approach to avoid creating so many nodes in Umbraco in order to replicate the content but I'm thinking there needs to be an intermediate step to cache or store the data being served.
j
We’ve done this before, but we had that intermediate step. When a product change was approved in a change request, it would push to a webhook that hit a service endpoint that would then take the data and index it in Elastic. You could use Examine to do this too.
Then we would do the request to the index instead of Salesforce for the front end display
s
Can you elaborate a little more on this? I'm not sure how the webhook plays into it. My idea was to decorate a product model with the data from SF directly. Not using UMB to edit or create new products if that makes sense.
j
Sure, no problem 🙂 The webhook was used to push the data from SF into Elastic Search so it's stored in a faster searchable instance whenever they changed the data in SF. Ultimately, SF API calls were very slow, so we discovered it was not particularly performant to pull the data directly from SalesForce. Putting it in the intermediate caching layer - in this case Elastic Search - made retrieving the data much more performant.
s
So, let me know if I understand the flow. A hook from SF pushed the data into Elastic Search. Then, what would get queried on the decoration process when the product page is rendered? If so I'll need to look into how ES and SF connect. Also, thanks this has been insightful so far!
j
Yes! Although frankly you could use Examine for this, too. Create a custom examine index in Umbraco and use it to cache the data. Honestly that's probably the approach I would take at this point 🙂
p
Great idea and similar to what I was planning to do. Out of interest - how do you serve the content? We are currently replacing a process that was syncing content to nodes in Umbraco and this has also been fraught with problems but when we change over we need to retain all of the existing content urls. We are moving to a headless solution which should actually make this bit a little easier to handle. Edit: I'm guessing you also need to do an an initial sync via the API before hand as webhooks are only for future changes.
Looking at the docs for v12 it looks like I can potentially do this via a custom
IndexPopulator
j
I wasn't part of the team that did the initial population, but since it's often a lot of data to pull in over APIs I'd probably be running it in batches, maybe as part of a hangfire job? For the render on the front, we use custom routing that serves them up by their Salesforce ID - something like
https://clientwebsite.com/products/{salesforceid}/
. We do not have them attached to any content nodes in Umbraco, but they do render in their own template that is displayed based on the routing and pulls from a model mapped to the SF data.
59 Views