How to announce to user when a Google Script is completed - google-sheets

On a Google Sheet, I have an extensive OnOpen script (viewable here) to refresh data on several sheets within the workbook. It all takes a while for all script lines to execute, i.e. to import new raw data and to then perform five different Unique Queries against that new data and thus update data on five sheets. When the Google Sheet is opened the user does see two successive pop-up yellow "Working" boxes, then five subsequent progress bars (while each of the queries do their thing). This all takes quite a while. I'd like to make an addition to the script routine to announce to the user that "all data is now refreshed and ready to view." A simple MessageBox ("Data now refreshed') placed at the end of the scripts seems to pop up before all script commands are actually completed. Thus the message box gives misleading info and I think it also interrupts some script lines from executing until "OK" is checked. So, MessageBox doesn't seem to work. So, I'm looking for a way to confirm that all script line (and all unique queries) are, in fact, complete before informing the user that it's OK to start viewing the data. Thanks.

Place a SpreadsheetApp.flush() before the "finished" alert box; the flush() method:
Applies all pending Spreadsheet changes. Spreadsheet operations are sometimes bundled together to improve performance, such as when doing multiple calls to Range.getValue(). However, sometimes you may want to make sure that all pending changes are made right away, for instance to show users data as a script is executing.

Related

VBA Receiving Compile error - Out of Memory

I have created a Main Userform that incorporates, multipage many fields and buttons and those link to various other userforms and worksheets and fields. I have reached a point where when I try to F5 I get an "Compile Error - Out of Memory"
I'm newer to troubleshooting these kinds of issues and granted I did not have a plan when I started in terms of structuring the forms and modules or what this would grow into.
This specific issue came having a Page that has a scroll feature that looks at a worksheet and pulls in records into various comboboxes based on a status of Open, closed, Hold etc. Each record is retrieving approx 7-8 fields and each page has approx 50 records that could display except closed which has to have enough for all.
I have read a couple things about ending Object to = nothing and enabling some advanced Windows to allow more memory allocation. I feel like maybe its a combination of structure and not clearing memory when i move around the tool. Any advise help or resources you could point me towards?
Attached is the Error, VBA project tree and a screen shot of one of the multipage items being pulled into the userform from the worksheet. (there will be multiple pages beside "open" that could have up to 100 or more records.
Thanks again,
Attached are Project Structure, error message, and userform-multipage screenshot example
Update: I was able to move past this, My issue was that I had a very bulky form that called a lot of textboxes and combo boxes upon initialization. This obviously required a lot of memory to render all this fields at once. Hence the error.
Solution: I re-thought the form and decided to use a list box and upon selecting a record from the list the fields I needed populate in the box below the list. This allowed me to go from hundreds of boxes to 12. This also was coupled that I had multi- page within a page. Sometimes you just need to take a step back and rethink and restructure your plan.

Run two keywords in Robot Framewok in parallel

I use robot framework with Appium library to automate an application.
I want to test there a graph functionality. When user long presses somewhere on the graph and holds his/her finger the values are shown for that date, as soon as user stops pressing the values disappear.
I tried to Long Press the graph and check that page should contain text or wait until page contains passing the expected text to appear, but the case always fails, as at the time when robot framework starts to check the text it is already disappeared.
So as I understand what I really need is to make two keywords run in parallel. The following two ones:
Long Press 5000
wait until page contains someText
I googled and seems that some time ago there was a way to run parallel keywords, but now they removed it from framework.
So does anyone know how can I test this case or is it possible at all?

Keeping a Google Doc (Sheet, etc.) last update time

I need to put (among other things) the time of the last update of a Google Document (Doc, Sheet, etc.) in a footer, so that if the document is printed it is possible to distinguish which printed copy is the latest. This needs to be a script so it is done automatically for users without requiring them to do anything special. I have a script that does this (at least for Docs), but there are some issues:
In a Doc there is no onEdit trigger, so I can't determine automatically when the document is updated in order to update the footer. (I am aware that I would need to prevent my own update from triggering this by ignoring the change I make)
onOpen can only update the document if the user has edit access to the document. So if somebody opens the document, edits it, and closes the window, and then another user opens it without edit access, they would see the next to last update time instead of the last update time.
The current version of my script must be manually bound to each document when it is created. Is there some way to have it automatically get bound when new documents are created? Would an add-on work?
Is it possible to use the "Detect Changes" API somehow? I'm not sure this is even going to do what I want, and it seems like it might be complicated to do it this way.
Would a time-driven trigger make sense? The only problem with this is that time driven triggers don't seem to be able to run more than once per minute (unless in an add-on, which can only run once per hour), so that last update time could be off by up to this much. This probably wouldn't be a big problem, but could occasionally cause some issues. Also, would running code every minute cause any kind of quota issues?
I tried using ClockTriggerBuilder with a delay of 1000ms, but it wasn't updating. Then I noticed that the after function says it will run the trigger after the specified number of milliseconds plus or minus 15 minutes!

How to monitor a long process in a JSF 2/Primefaces/JBoss application

I have a JSF 2/Primefaces/JBoss application that has to run some long term processes from time to time. Specification says that once the process is started, its progress has to be monitored, showing the occurrence of intermediary phases of it.
The total count of steps is retrieved in the beginning and a progress bar has to show the process evolution and and estimate of the remaining time, based on the statistics calculated during the process execution. It's not like only showing that something is happening, but actually showing how much the process still remains to be done.
Even if the user closes the page, the process has to continue and if the user gets back to the page, it has to show the current progress status of the process. If the process is already finished, then some informations should be presented, like the number of objects processed and, the total time taken and some other statistics, like the object that took longer to be processed.
How to accomplish that in a JSF 2/Primefaces/JBoss application?
You question can be broken down into two main problems.
1. How to log and track the status of a job.
2. How to present this information in the UI.
Depending on your requirements and your JBoss version, you may want to consider using a managed thread. You must decide how you will track the process steps. You could log each completed step in a database or keep it in memory. How will errors be handled? What if the process does not complete? Once you have these back end design decisions completed and implemented you just need to figure out what you want the UI to be like.
As mentioned in the comments section, primefaces offers a couple different options such as polling or server sent events. If you are using polling leaving the page and revisiting should already be handled by presenting the result for any point in time. You would then just need to refresh the view on an interval.

What is the best way to implement dynamic search on the server from iOS application?

I'm struggling with a problem of implementing dynamic search.
Here what i want to achieve:
In my application there is an option that user (program manager) will be able to search his team members. Each PM has its account on the server side (web service) where it is a table team_members which contains all the team members that correspond to this manager.
Their amount can be more than hundreds.
And client side app which I develop has an option search team members.
I want to implement it dynamically:
e.g When the user print first letter a I make a query to the server and get all the matches with a letter: Antuan, BArrow, etc.
Then user print ab and I make a query which must return Abraham, Abdulla, etc. And so on. All the matching results is shown in UITableView.
HTTP query to server is made each time text in UITextField shanges. I implement it with dispatch_async: on UITextFieldTextDidChangeNotification I create a dispatch_async where i make an HTTP request with searchbar.text.
The problem: it works very slow. I often get an exception bad selector was sent to the instance.
So my question:
Why is my approach bad? What is a better solution for this?
Or dynamic search it is a VERY bad idea and I must do search only on clicking some button?
Thanks. I hope some experienced iOS developers will give me good advice.
Making an HTTP request every time someone types a character is probably never going to be fast enough (nor does it really make sense -- read on). For a certain size of list, the answer would be to pull over the whole list in the background as soon as you present the field (but before the user starts typing in it). Once you have the list, you can start matching, in memory, on the local device. "More than hundreds" isn't very specific, and it depends on network speed, but I'd guess that if your list is less than 50K in payload size, pulling the whole thing will be the easiest way.
If the list is too big for that to be practical, but the list limited by the first character the user types is not too big, then the best approach might be to wait for the first character, fire off your HTTP request asynchronously, and only start the dynamic match once you've received the response containing all items that start with that letter. One thing to keep in mind is this: if you have the list limited by the first character, that's the only HTTP request you ever have to make (unless the user changes the first character) because all possibilities starting with that letter will be in that list. From there, you can pare down the list locally without any further HTTP requests.
As for why you're getting exceptions, it's hard to say without seeing your actual code. Try setting an exception breakpoint in Xcode. This will allow you to stop in the debugger when the exception is thrown, which will show you what's causing it.

Resources