How to maintain a View that depends on a time-based CoreData query up to date in SwiftUI? - core-data

I have a view that shows flashcards to the user. The user reviews the cards and when there are none left to be reviewed, the view shows a success screen.
Each card is stored in CoreData and has a due_for_next_review_date field which gets updated on each review. Currently when the user finished reviewing their cards, they get their success screen, but there is no mechanism to let the view know that some time has passed, and a card's due_for_next_review_date field has gone below the current time, and that it should therefore now be shown to the user. They have to exit and re-enter this view to refresh the cards for review, which is not ideal.
Basically what I want is a way for my view to poll CoreData and check if any cards have had their due_for_next_review_date field go below the current date, and should be shown. Is there a way to do this? I've tried TimelineView, which lets me re render the view, but the view doesn't re execute the CloudKit query regrettably.
Anyone know how to do this?
Thanks.

Related

How can I trigger a NetSuite workflow on a Form Event (Client side event)

I want to trigger a NetSuite workflow when the user sets the value of a field, but I don't want to have them submit first. The Workflow state builder looks like it has useful options but I can't get it to work.
There's some useful looking blog posts around but a lot of them seem out of date.
Update - more info
My primary issue is this one: Restrict what customers an employee can see (NetSuite)
The hack I'm currently looking at is populating a custom Transaction Column Field that I've added to a custom Time Recording form. The idea is to load this field on the UI with only valid projects (not customers as well), and this I have been able to do.
The problem is I still (as far as I can tell) still need to populate the "Customer" field, which is mandatory; I'm also assuming that if I don't do that then any time that is recorded won't go against the project. I had thought that if the user selects the project they want then I can populate the customer field with that value. I hate this as an approach but I can't see how else to do it. I do have coding experience (including JavaScript) but haven't made the leap into SuiteScript yet.
You won't be able to do this in a Workflow, as they are currently limited to only work with body level fields and cannot modify Transaction Column Fields (aka sublists).
You should be able to achieve this with a Client Side Script though.
Source (Netsuite login required).
Sublist changes will be available for transactions in the 2018.1 release sometime in Feb/Mar.

update netsuite parent field via suitescript in view mode

I have scripts that react off of, for example, a client Recalc client event. For example, on my form I have a subtab that users may add or remove items from. Based on actions on this subtab (housing a child record of the parent) I would like a field on the parent to update (say to show a total from the children records).
As I was saying, these events seem to work fine if in edit mode but they do not work correctly in view mode. (even in view mode these child records have a "Delete" option at the end of each row in the subtab. This was provided by netsuite by default.
I wondered if anyone had any tips to best allow this parent field to update real time while in updating the subtab rows with the form in view mode.
Thanks.
You can make a custom field on the parent (header) whose value is determined by saved search. For instance, make a saved search that totals the line values by transaction. Be sure to make it filter by transaction in the Available Filters tab. Make the search public so everyone can use it.
Create the custom field that sources the total from the saved search. Make sure to uncheck the "Store Value" checkbox, as you don't want to store the data, you want to reference the search results. You do this on the Validation and Defaulting tab. You'll see a field for Saved Search there. Choose the search you created above.
As you remove/add/change lines on the transaction, the field updates accordingly. In essence, you don't need a single line of code to make this work - it's all in how you create the search and the custom field that references it.
I have a similar situation posted here.
The NetSuite team answered me by email, and it happens you can't really achieve this on the view mode: some API methods are not available. Their suggestion to my case (and I think it applies to yours too) was really to force a refresh on the whole page.
Of course, you can always achieve this accessing the DOM elements directly, but this isn't a best practice, as your code can stop working if these elements change on a version update.
I had the same problem, I'm not able to restrict on view or remove edit button. But, there was one alternative solution with workflows, you can deploy workflow on child record edit mode restrictions, then if the user clicks edit on view then the record will not be available to edit. This concern will apply to custom record as well.

Lotus Notes embedded view not working for one user

I have an embedded view in a main form (same database) with a single category of a client code that is custom generated. The view displays all other documents that have that main document's client code in a hidden field.
This works perfectly, except for one user where the embedded view is blank, and the message "category not found" is displayed. This happens for all documents viewed. Anyone else that opens the exact same main documents can see the correct list in the embedded view. The documents are definitely there.
I've pressed F9 a few times, and the "category not found" keeps coming up. I've also shutdown Notes and deleted the cache file, and restarted. There have been no changes to the database for a long time, and this started for this one user a few days ago.
I have no idea whats causing this.
Check readers/authors fields in documents that should be displayed in your embedded view. May be that user just can't see them.
Before I get too stressed, I generally try this:
Remove the database from the user's workspace
Compact the workspace (2nd tab of workspace properties)
Close Notes
Delete cache.ndk
Restart Notes
If that doesn't work, I'd check that the user can see the documents in another way (i.e. if you send a doclink to the user, can the user open it (alternatively, try opening the embedded view directly through View - Goto. Don't forget to use CTRL-SHIFT at the same time if the view is hidden)? If not, the user may have lost a role, or dropped out of a group that provides access.
¿The view is "shared" and not "shared, private at first view"? In that case, you have to delete de "private version" of the view for that user
¿The embedded view is calculated, and show one view for a group of users and a second view for another group? Maybe you're searching the problem in the wrong view
¿The single category is based on a formula or on a calculated field? In that case, the formula calculates a different value for that user

Best approach for implementing Insert/Edit of Core Data Entities

Let’s suppose there is an entity called PERSON in a CoreData model and a NSPanel (displayed as a Sheet) is used to ask for the information needed to create an instance of such entity. The NSPanel also has a Save and Cancel buttons.
What would be the best way to implement this?
My current approach is to create the NSPanel and add outlets to NSTextField’s corresponding to the FirstName and LastName attributes of the PERSON Entity.
For the Save button I’ve created a Save Action that “reads” the data entered by the user through the Outlets and manually create a PERSON Entity with the provided information.
For the Cancel button, I’ve created a Cancel Action that just closes the NSPanel.
Even though the whole thing works as intended, I find this approach messy. Things get even worse with the need to implement the Edit functionality since a new method is needed to read the data from the selected Entity and pass it to the NSTextField’s, and add the required logic to the Save Action to account for the update operation.
I wonder if a full CoreData/Binding approach is possible in this scenario?
The main issue with the Full CoreData/Binding approach, at least to my short experience on these frameworks, is the fact that once the user start entering the info on a new instance, is already to late Cancel operation. Right?
The setup you describe is by no means messy. Rather, it provides ample opportunity to enhance the UI experience.
Your last point, or "main issue", is not a problem at all. You can put up the NSPanel and have the user input new values, and simply dismiss them if Cancel is pressed. Only if the Save button is pressed do you insert a new object into the core data managedObjectContext and save.
Similarly, when editing you simply retrieve the data before and populate the fields. You keep a reference to the record, if Save is pressed you modify the attributes and save the managedObjectContext. If the operation is canceled you simply discard the reference.

How should an IPhone notification-type application show user there is a notification unobtrusively

I have a program that basically just queries a webservice, and if any data is returned it will show that information to the user, but if there is nothing to display it will just wait until the next scheduled time and run.
Right now it just puts a table in front of the user, there is nothing in the status bar that they can then select and see the actual information.
So, I have two questions.
Is there a better way to show
notification information to a user
that is less intrusive?
Should the View, with a UITable,
have a button to dismiss the view
when they are finished?
UPDATE:
It seems my question isn't clear enough, so I have the data showing up in the table properly.
My problem is before I display the data.
Currently, periodically the timer will fire off my method, and if there is any events pending for the user the table will show up right in front of them.
That is bad design, IMO, so what I would like is some simple way to let them know that there is something pending and they can look at it when they get a moment.
Ideally I would have something in the status bar to show that they have some events, but it appears that isn't an option that I can see.
One option is to see if I can have the table come up minimized and have some sound or vibration go off, but again that can be bothersome to the user, as it may interrupt what they are doing.
The proper solution appears to be that while in the background just put up a notification if there is any new information, so the user can close the notification or switch to view the details.
This isn't the ideal solution, but appears to be the best choice on the iPhone.

Resources