Button Enable-disable in Popup

0
I have popup when “yes” button pressed its calling a microflow to update 1 list value , now i want to restrict that button to update values only one time in a month . so i want to disable button for a month and re-enable in next month  how can I do that ?
asked
4 answers
0

What you will need to do is the following:

  • use the changed date function of the entity
  • on click of the button call a check that runs the following check
    • is the difference between currentdattime and changeddate > 30 days
    • (use daysBetween( currentDateTime, ChangedDate))
  • if this returns a true, run the flow
  • if it returns false, give the user a message stating how many days are left before the flow is allowed and stop the flow (of course)
answered
0

Hi,

As exactly said Geoffrey,
 

  • You can create an Boolean i.e MonthVisibilty and Month(DateTime) Attribute
  • After the first hit of microflow -->Check the month is equal to current month and check the MonthVisibilty  is True
  • If its true then popup to shown with buttons and Add one month to Month by addmonths()
    https://docs.mendix.com/refguide/add-date-function-calls#8-addmonths-utc
    and in the functionality flow set the MonthVisibility to False
  • If its false then dont show that popup(Handle in microflow)
  • After the second hit of microflow on same month then MonthVisibility return false
  • First hit for Next month will satisfy the current month functionality and set the MonthVisibility to True
    ​​​​​​​Flow Continues
answered
0

Hi Vineet, 

The solution suggested by Goeffrey will work. You, however need to be aware of the changedDate attribute (the default one) being updated with every updated to the entity. So, if this entity is updated somewhere else in your app, the changedDate is also being updated.

What you could do to overcome is to add another date attribute and update it during the button action (you mentioned in your original post). 

Another thing to mention is that Goeffrey’s suggestion to calculate the daysBetween will mean that you will be able to continue running the microflow after 30 days from the update. If, however you want to be able to run the microflow every month once (i.e. once on the last day of the month and second time a day later), you would need to check if the month’s part of the current date is greater than month’s part of the “entity changed” attribute (most likely including also the year part, so something like ‘yyyyMM’ or use the trimToMonth function and check which is greater). 

Hope this helps. 

Cheers, 

   Bart 

answered
0

Hi ,

There is many ways to do that and also from your question there is many scenarios my suggestion to do a schedule event runs every month to update the list ,Now the process is automated .

Also if you can give us an example ,you pass an object to the popup or not ? is this action done one time for all the application or user action ?

answered