Selecting Individual texts at scheduled time
Question

How do you select individuals texts for a list of texts to be displayed at a scheduled time like every 24 hours or 12 hours?

Any help would be much appreciated.

Hi Olamide,

I'm understanding your question as : there is some screen or block that displays a single piece of text, and the content should be different, depending on time, right ?

So a solution could be to create an entity, with attributes text and effective_from datetime, and you scaffold screens to fill this entity.  In your screen or webblock where you display a text, just read the entity sorted by ascending datetime with datetime >= currDateTime(), with a MaxRecords of 1.

So what you do in above solution is assume that effective_from of a new record in your entity, silently puts an effective_until on the previous one.  This is easiest if you want to avoid gaps in your timeline where no text is effective.  But if for some reason you would want that option, just add a 3th attribute effective_until to your entity and add an extra filter <= effective_until to your aggregate.

Alternatively, if you don't want your users to have to tell at what time what text becomes effective, you could remove the datetimes, but give them some sort of sequence and a boolean saying which one is currently effective, and have a timer move that forward every day.  This way you can just have a list of texts, and circle back to the beginning of the list when you reached the end, maybe that's more like what you want ?  And then your aggregate just has to filter on that boolean.


Dorine

hello

So I didn't understand all that you said before so I tried to acquire some more knowledge and This makes sense now

So I made an extra attribute and named It datetime and I put the date and time for each record for when I wanted the record to show and I set the maxrecord to 1

All I am asking now is is I followed the instructions correctly and how I know if it works?

Also could you elaborate what you meant on the last paragraph because that is ideally what I am trying to achieve, just having the text display one record at a period of time and just circle back to the beginning after it is done.

Hey Olamide,

I saw you repeat the same question, and figured maybe you would catch on to what I tried to say here.

And yes, there you are   ;-)

So the alternative i propose is to have for example 2 attributes instead of datetime : a unique sequence number for each text and a boolean saying ´ IsCurrentText´  

And you have a timer running every day at midnight, finding the one with boolean true, setting that back to false, and setting the next one in the sequence to true, and when you are at the end, setting the first one to true.  Your screen aggregate should then have a filter IsCurrentText.


Or have a separate table where you keep track of the current sequence number per user, and your midnight timer just adds 1 to each, or puts back to 1 when you reach the end. In this case your aggragate filter would be a bit more involved, maybe for you at this point a bit too much to take on.

Happy coding,

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.