Copy Salesforce Production data to a Sandbox without third party tools/connectors - salesforce

I am new to Salesforce and got the project of copying prod data to sandbox.
The question is, how can we insert data from production to another sandbox.
Is it through rest call, if it is so then at destination sandbox as well we need class to listen that rest call. But that is not a requirement, what they want is application should be in production box only and on giving correct creds for destination box, data should be copied from production to destination box.
Please suggest me best ways available in Salesforce to copy data from prod to another sandbox using Apex class and triggers.

If you have a middle wear system that you could fire an event to which would then trigger listening sandboxes to pick up the data that you are subscribed to. You will need to create a RESTFul or Soap service either way, it just depends on if there is an event fired. I recommend that you broadcast an event so all sandboxes subscribed to that event can pick it up.

Related

Raise an event notification to a specific client when a user is registered/created on Identity Server

I am creating an AdminUI for my users where I set all the permission. As part of the requirements, every time that a user logins on my IdentityServer I need to set some default permissions, but those are handle on my Admin application. Which is the best way to raise an event to let that application that a user was created on the IdentityServer?
The simplest is i think to create a simple WebApi in IdentityServer that returns the latest users and then let the other application poll this API every X seconds. In that way the system is cleanly decoupled. Perhaps expose the data as a a RSS XML document or a JSON list of items.
There is a built in eventing model in IdentityServer that you could use and push notifications to the Admin application. But push is a bit more complicated to get right, especially how to deal with all the failre/error cases.
I's suggest to add a custom event sink to process UserLoginSuccessEvent or any other event you need, here is list of all builtin events. Find their code here.
In the custom sink as suggested in the other answer you can call an API on admin app to inform it about changes.
Here is a sample for custom sink.
I think to keep two applications decoupled you better to setup a service-bus for simple implementation a sub/pub mechanism. when any user complete registration(or any other actions),then as mentioned in another answer handle the events and add message. admin UI should subscribed before to receive these messages with some information to create a user related data.

How to add multiple subscription in Azure Logic app Service bus topic trigger

As I am having a logic app where the trigger is service bus topic subscription. I want to add multiple subscription ("A", "B","C") for the given topic in my logic app service bus topic trigger . Whenever i select topic it only allows me to select single subscription. Is there any way to add multiple subscription from an array or static variables ? if yes then how to add conditions ? I tried using array, but i have to provide the index of the subscription.
I can use multi trigger logic app for all of the subscriptions to achieve what I am looking for, but is there any other way like using some wildcard characters ***** or / or something else which i am not familiar with .
The action supports selecting only one subscription as you have observed.
Multi Trigger Logic App is indeed one way to go about it but note that the designer doesn't support them, and you will be forced to edit only using the code view.
One alternative would be to split your logic app into two
one for your business logic that is triggered by a HTTP request
one (or more) that is triggered by the service bus subscription trigger and calls the first logic app
Another alternative is to leverage the Event Grid Integration in Service Bus, but note that this is currently applicable only for the Premium Tier.
In this approach, the logic app would trigger based on an event message from Event Grid with details of the subscription that has messages ready to process. You would then use the Get messages from a topic subscription action to fetch the messages to process.

How do I keep a database of repo stats and user stats, in sync with github?

How do I keep a database of repo stats and user stats, in sync with github?
I know that I can use
curl https://api.github.com/repos/reggi/handwritten
and
curl https://api.github.com/users/reggi
To get repo and user data.
But what's the best way to keep that in sync with my database?
I don't believe theres a webhook for this general data, like when a stargazer gets added.
Should I just have a cron script that updates the database daily?
I don't believe theres a webhook for this general data, like when a stargazer gets added.
There is one event related to stargazing, and strangely enough, it is the Watch Event.
See "Upcoming Changes to Watcher and Star APIs".
More generally, using WebHook is a good way to be kept in sync with a lot of events regarding a repo or a user account.

AngularJS: combine REST with Socket.IO

In the single page webapp I've recently built I'm getting data for my models using Restangular module. I'd like to add real-time updates to the app so whenever any model has been changed or added on the server I can update my model list.
I've seen this working very well in webapps like Trello where you can see the updates without refreshing the web page. I'm sure Trello webclient uses REST API.
What is a proper way to architect both server and client to archive this?
First of all, your question is too general and can have a lot of solutions that depend
on your needs and conditions.
I'll give you a brief overview for a single case when you want to leave REST APIs
and add some realtime with web sockets.
Get all data from the REST -- Sokets for notifications only.
Pros: Easy to implement both server side and client side. You only need to emit events on the server with
info about modified resource (like resource name and ID), and catch these events on the client side and fetch
data with REST APIs.
Cons: One more request to the server on every notification. That can increase traffic dramaticaly when you have a lot of active clients for a single resource (they will generate a lot of reverse requests to the server).
Get initial load from the REST -- Sockets for notifications with data payload.
Pros: All info comes with the notification and will not cause new requests to the server, so we have less traffic.
Cons: Harder to implement both server side and client side. You will need to add data to all the events on the server. You will need to fetch data from all the events on the client side.
Updated according to the comment
As for handling different types of models (just a way to go).
Client side.
Keep a factory for each model.
Keep in mind that you need realtime updates only for displayed data (in most cases), so you can easily
use memory caching (so you can find any entity by its ID).
Add listener for every type of changes (Created, Updated, Deleted).
In any listener you should call some initObject function, that will find entity in the cache by ID and extend it, if there is no entity with such ID, just create a new one and add it to cache.
Any Delete just removes an entity from the cache.
Any time you need this resource, you should return the link to cache object in order to keep two way databinding (that is why I use extend and not =). Of course, you need to handle the cases like: "User is editing the resource while notification about deleting comes".
Server side.
It is easier to send all the model then just modified fields (in both cases you must send the ID of resource).
For any Create, Update, Delete event push event to all engaged users.
Event name should contain action name (like New, Update, Delete) and the name of resource (like User, Task etc.). So, you will have NewTask, UpdateTask events.
Event payload should contain the model or just modified fields with the ID.
Collection changes can be handled in two ways: with add/update/remove items in collection or changing all the collection as a whole.
All modifications like PUT, POST, DELETE are made with REST of course.
I've made a super simple pseudo gist for the case 1). https://gist.github.com/gpstmp/9868760 but it can be updated for case 2) like so https://gist.github.com/gpstmp/9900454
Hope this helps.

How do I create an Outlook calendar subscription from my web/app server?

I have a website that is a calendar with all the basic features (ASP.NET MVC and SQL Server). People can enter events, view others events, etc. One person asked me if there was a way they can see these events in their Outlook calendar - as a second calendar.
I have all of the data on the server. Is there a recommended way to have Outlook point to my web server or DB for a calendar? I see there are ways to generate iCal files from C#.
If so, how would this data stay in sync as new events are created, deleted, etc? A one time dump would be ok but the concern would be that the data would get stale. Is there a solution that would keep the reference dynamic to keep them in sync. (it would only need to be a one way transfer, i don't expect the need to create or delete from Outlook, so outlook is just read only)
I think you can create iCalendar file,then publish it ,so let clients subscribe your internet calendar because internet calendar subscription is periodically synchronized with a calendar that is saved on a web server,and any updates to the internet calendar are downloaded automatically into MS Outlook.
You can use DDay.Ical library for creating (.ics) files using C#.
assuming your question is about how to keep the client and server side synched, and since you only mention outlook as client, there is a custom way to control the update frequency: microsoft has a custom calendar property: X-PUBLISHED-TTL (see microsoft msdn calendar)
2.1.3.1.1.15 Property: X-PUBLISHED-TTL
Brief Description: Specifies a suggested iCalendar file download frequency for clients and servers with sync capabilities.
however note that this property being custom will be ignored by other calendars
You could try to keep track of the SEQUENCE of updates to each calendar entry in your database, and add a trigger on your table of calendar events so that it would automatically send event updates when something changes. Each update would have a higher SEQUENCE property than the updates that came before it, but the UID (the event's unique identifier) would remain the same.
For this to work, though, you'd need to be able to send iCalendar events from within your SQL Server, which can be possible using the following CLR project:
github.com/EitanBlumin/sql-clr-ics

Resources