salesforce trigger to update a visualforce page - popup

I am fairly new to salesforce and I'm having a problem statement which I'm unable to solve.
There is a Custom object named XYZ which has the fields: username, points and Id. Now I want that whenever a particular user points gets updated I get a pop up notification in a visualforce page. I am fairly familiar with the concept of Trigger but I don't know how to use that trigger to update the visualforce page with a pop up notification.

I think you may want to rethink your approach. Triggers are completely data driven, and will perform an action on data within the database, but they aren't going to give you any kind of interaction on the front end save for error messaging.
Your details are a little sketchy, but for the pop-up you probably want to use a Javascript alert, or maybe even some kind of modal window.
If you give more details about the process you're trying to achieve it might be a little easier to give you a more solid response.

Finally, I ended up changing my approach and creating a PushTopic for the update. And subscribed to this PushTopic using cometd javascript library.

Related

Track data for my own action dimension in Matomo (without custom dimensions plugin)

I need to track some user activity like special clicks, scrolls, and mouse drags, combined with the data I get from the website's back-end.
At first I did it using custom events and created a plugin to read them and generate the reports. But events have their own limitations (like number of archived table rows, ...) and did not fit my use case. Besides events get shown on other reports and views and I don't want to clutter them by my too many events which do not have any meaning out of my plugin's reports.
Using the custom dimensions plugin would not work for me. It is limited and I want to develop and publish my own plugin to my customers.
So I created my own action dimensions.
My plugin works well with the action dimensions I added, and can receive the data from user's activity if I use my previous custom events to send the data. But I don't know how to send my tracking data to it without using events.
I searched for it in Matomo forum, just found some similar questions beening unanswered for a long time.
So my main question is:
How I can send the data of user actions to my plugin's dimension without using events?
Also, am I on the right track? Is creating my own action dimension the correct way to do it?

How to send push notification when data changes from API

I'm currently creating an iOS application in Swift that fetches data from a third party API and then displaying it on the screen.
One of the features includes enabling push notification so that the user gets a push notification if there's a change in the API data.
However, I'm struggling to figure out how to implement the push notification side of it so that I can constantly monitor the API data and then send out a push notification when there's a change in the data.
Can someone point me in the right direction on how to do this? I've previously used Firebase to implement push notifications but the push was triggered from a user action. I was wondering whether there's something similar I can utilise in Firebase or if there's any other recommendations?
Thank you!
You may be able to use cloud functions. If you're monitoring the data client side you can perhaps make a call to a cloud function to send a push notification.
Or you may want to look into local notifications. I'm not sure exactly what you're trying to accomplish so it's tough to really say, but as far as a direction goes I would recommend checking out cloud functions and local notifications to see if either one solves your needs.
Edit:
Now that I know more what you're looking for I would check out this article here. It will explain about Background App Refresh. Here's an excerpt from the article.
When the system calls your app delegate’s application(_:performFetchWithCompletionHandler:) method, configure a URLSession object to download any new data. The system waits until network and power conditions are good, so you should be able to retrieve adequate amounts of data quickly. When you finish updating your app, call the completion handler and provide an accurate result of your outcome, which can include saying that no new data was available.
So in the application(_:performFetchWithCompletionHandler:) method you would want to:
Download the new data
Compare it to old data and see if there's been a change
And then probably I would just display a Local Notification to the user.
I think that would be the easiest way with your current architecture and without having to write any server side code.

*When* do you save data from an edit control in a Xamarin Forms listview?

I could not think of how to best phrase my question, so what you think I'm asking is probably not what I'm asking. Pretend that I've got three working apps, but the needs of this fourth one are a little different, so I'm asking for advice / best practices, not how to write an SQL statement, code a listview, customize a viewcell, or how to bind to a datamodel. I've got all that.
The TLDR version:
What I need is a sane way to know when the user is done entering his data so I can push it to my server.
I know that there are people out there who have solved this problem, so I'm soliciting your advice. If you also did not want to do a save on every keystroke, I'm especially interested in your recommendations.
Here's the slightly more detailed version:
I'm writing a companion app for part of our desktop software, which uses a proprietary data server to store its data that I can access from the mobile device. In my previous apps, I have a screenful of controls. The user enters/modifies data, and I know to save to my local sqlite table when they exit the screen. It's basically a transactional model, and I only upload the data to our server when they press a button to do so. Works great.
However, for this app, instead of entering a screenful of information, the user is just entering numbers in a list. Think inventory: user has a list of products and quantities, and they update the quantities to match what they've got. The user will not leave the data entry screen often, and is likely to turn off the device, or kick the app out of memory without "going back", so my datamodels can have unstored data.
I have entry fields in a listview. I need to push the entered data to my sqlite table, then on to our proprietary data server. I would have thought to do it from the property setter in my datamodel, but sadly that gets called when the datamodel is initially bound, AND on every keystroke.
I know that there are lots of people who have coded data entry in a listview, I've read all the posts to figure out how make the viewcells work. I am primarily using Entry controls, and I have tried using TextChanged, Completed, and Unfocused. Each one has some sort of issue that makes it an undesirable solution "out of the box". I've got some ideas and know how to solves parts of my problem, but am hoping someone out there has a much better solution than my collection of little hacks.
Obviously there's a ton of details (and complexity) I'm leaving out. I am using a view - viewmodel - model architecture, but am not using MVVM or any similar framework. My solution needs to be in "vanilla" Xamarin Forms.
Thank you so much for your help!
I would comment but I don't have enough reputation, so here it goes.
Is there a specific reason a button can not be added to the page (below the list view), so that the user can press it when they are done taking "inventory"? I'm assuming this is part of the complexity/details you are leaving out.
Without a button, you could make the data save/push happen using an Unfocused event on each entry field. If the user filled in a value for each entry control, the unfocus event could call the method to save the data. The code-behind would get a bit cluttered and it could be messy if you have a long list of entry controls, but it would get the job done until you find (or create) or better way.
Hope this helps.

How to build realtime push notification feature like facebook does? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm going to build realtime push notification feature for my web application ( a small social network) and I don't know where to start.
This is what I want to build: there are like buttons, comment forms, ... Users click like, write their comments and (relatively) immediately, on the owner's browser shows the number of new likes and comments, ... Something like that.
I've read about socketIo on nodeJs, MeteorJS but unfortunately, they need WebSocket supported by mordern browsers. I've just read about Comet technic and find it pretty easy to apply. But i'm not sure it will performs well because Comet relies on long-polling connection (correct me if I'm wrong).
In addition, I think facebook is using Comet for its push notification feature. Through console tab on firebug plugin I can see there's alway a holding connection to facebook.
So can anybody show me a technic, a model to develop a feature like that?
A promising idea is to work with the HTML5 notification API; it's perfect if you want notifications to pop on the user screen as long as his browser is running (even if you're surfing another website or if all windows are closed).
http://www.paulund.co.uk/html5-notifications
However, if what you want is to update different parts of your page asynchronously (without refreshing or pushing a button), you should use together :
Ajax calls;
Listeners and observers.
When you Ajax calls retrieve particular types of json data (for example), it can trigger appearance of a badge (listener) with a number of new notifications, or so...
With JQuery installed, you should be fine...
Even though it's often not the case, sometimes, for simple tweaks, it's easier to code the job done...
You can start here :
How implement a "observer" in Jquery without plugins? (it's old, but interesting)
Or see this page :
browser instant updates with ajax/jquery
(incredible how often google queries return stacko' pages)
You should check out MQTT. It basically works on the Publish-Subscribe model and is very easy to use. This protocol has a small footprint and consumes less bandwidth. Facebook's Messenger uses MQTT too.
you can use an ajax call coming into (for example) a php script on the server, which keeps the connection open and only replies if and when something needs to be displayed to the user. should nothing happen within a certain time, the connection gets closed and the client fires a new ajax call.
note that this only addresses the client/server communication, you would still need a notification method inside the server to wake up the php script if you want to avoid having a script constantly polling the database, but there are quite a lot of soultuions to this and they depend on what language you use on the server.
I have got an idea, it is simple but it may work. Why don't you hide notification bar as Div tag and design it with css to make it look like notification bar. Then whenever some user likes or comments about the page, write php or js function and connect it to like or comment submit button that will reveal page owners invisible div to visible. And I believe , depending on what you use, I would probably prefer php session() to Identify if page owner is online and can get notifications. moreover, if you need to track statistics of the page, you may create a small database that holds, page id and user comments. You can use this database to push multiple notifications on that hidden Div. you can use Jquery to make it move like Facebook if you want to. I m not %100 percent sure if this is the most optimized way to do that but it is possible. By the way, I surfed some to see what people use to do that. surprisingly I couldn't find something as well.

New/Read Flags in CQRS

I am currently drafting a concept for a (mostly) HTML-based collaboration suite which I plan to implement using CQRS. This software will contain messages that can be sent to the user (which can either be read or unread, obviously) and other elements which shall be marked "new" if they were created after the last user login.
Hardly something new, but I am not quite sure how that would be correctly implemented using CQRS. As I understand it, Change of any kind should, without exception, only be possible via Commands. But creating commands for every single (new) element that is being accessed seems a bit too much, not to mention the overhead.
I don't know if I need it, but what would be the best way to implement a Last-Accessed Timestamp on elements. Basically the same problem like the above, with the difference that the change happens EVERY time the element is accessed, not only the first time for each user.
CQRS seems to be an awesome concept but it really needs more learning material. Can't wait till a book is released :)
Regards
[Edit] No one? Wouldn't have thought that this is such a complicated issue..
I assume you're using event-sourcing in which case once you allow your query-service/event-handlers to raise appropriate events then this becomes fairly easy to solve.
For your messages/elements; when handling the specific creation events of your elements either add to existing or create additional event-handlers, to store to a messages read-model with a status of new and appropriate information about the element.
As part of you're user login I don't see why you can't raise a user-logged-in event (from the security/query service depending on how your implementing authentication) to say the user has logged in. An event-handler could capture this and write the last-login timestamp to a specific user-last-login read-model.
In addition the user-logged-in event-handler would need to update all the new messages (for that user) to an unread status. Seeing as we're changing the status of the messages as the user logs in do you still need to store the last-login timestamp?
For your last-accessed timestamp, perhaps you could just work this into your query service as queries for your different elements complete. Raise a query-completed event with element id/type information.