Forum Academy Marketplace Showcase Pricing Features

Setting a constraint for a repeating group: expiring posts after 14 days

Whats up bubble community,

I’m trying to put a constraint on the data I want my repeating group to display.
In real language: I want to expire posts that users make after they are older than 14 days.

In bubble language, the expression is confusing me! And I’m not sure how to test it without waiting for 14 days! haha!

Here’s my screenshot. Please help me phrase the expression for the constraint properly!

Hello :slight_smile:

That looks about right. Another way of doing it would be to schedule an API Workflow for 14 days time that updates a Yes/No field “Expired” on the database to “Yes”.

In terms of testing, you could maybe change the time on your machine

Hey Thanks @NigelG . I’m still on a tricycle when it comes to Bubble and APIs, so I’d like to avoid those [for the short term] if I can achieve the desired constraint with the math expression.

After sleeping on it, here’s what I’ve got.

  • post is made Jan 1
  • want it to last 14 days
  • takes us to Jan 15
  • repeating group constraint should limit the post from being displayed after Jan 15

In math terms: the created date + 14 days should be less than the current date.

But, Bubble forces me to rearrange that equation. See screenshot. So my question is now: are NEGATIVE days possible?

In math terms: the created date should be less than the current date +days NEGATIVE 14

Yes you can, just put a minus sign (-) before the number value

So you will want to use:
Created Date > Current date/time +(days):-14

1 Like

Don’t forget the time component when you are comparing. It might not matter in your case for a post to expire in the middle of the afternoon because that’s the time it was created. Or it might matter!

I am trying to accomplish the same thing, but want to make the number in the end of the expression be a dynamic value, based on the value of a slider on the page.

However, whenever I try to combine the minus sign with the sliderinput the value in the expression becomes 0 and it doesn´t seem to work.

Any way around this? Thanks!

Just have a property like "expire_day, which would be a number and populate it

You could use a Custom State on the Slider Input that is the Negative value of the Slider, and then reference the state’s value instead of the input’s value.

So in the workflows you would add:

And then you can reference the state’s value:

2 Likes

What a great and clear answer, thank you!