web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Business Rule not trig...
Power Apps
Answered

Business Rule not triggering on a Calculated Field in Model Driven Power Apps

(0) ShareShare
ReportReport
Posted on by 231
Hi,
I have 2 column fields on my "Date" Dataverse Table in Model Driven Power Apps. The fields are "From Date" and "To Date". 
I wanted to ensure that while creating a record, my "From Date" and "To Date", should not lie in same calendar months.
 
To ensure this, i created a Calculated column named "DateDiff" using Formula and the formula is DateDiff('From Date', 'To Date', TimeUnit.Months).
 
The formula is running fine and giving me correct values, but it is not triggering on my Business Rule, in which i mention that:
If DateDiff filed is greater than zero, the show error message at "To Field".
 
After having multiple runs, i came to conclusion that since DateDiff is a calculated column, which triggers only after "From Date" and "To Date" fields are filled in and saved, the "Business Rule" is not getting triggered.
 
Please let me know possible way around?
I have the same question (0)
  • Verified answer
    Inogic Profile Picture
    1,291 Moderator on at
    Hi,
     
    In Model-Driven Apps, a calculated column is evaluated only after the record is saved. Because of that, your Business Rule will not trigger immediately when the user selects “From Date” and “To Date”. That is why your validation is not working in real time.

    Why this is happening: The DateDiff calculated column updates after save, but Business Rules work on form data before save. So the rule does not detect the calculated value instantly.

    The best and simplest way is to use JavaScript on the form instead of a calculated column. Add a small script and run it on the OnChange of “From Date” and “To Date”. In the script, compare the month and year of both dates. If they are in the same month, show an error on the “To Date” field. This will work instantly before saving.

    Another option is to use a synchronous plugin on Create and Update. In the plugin, check both dates and throw an error if they are in the same month. This will prevent the record from being saved.

    Hope this helps.
     
     
    Thanks!
    Inogic
  • SA_VOH Profile Picture
    231 on at
    Hi @Inogic,
    Thanks for reply. Apologies for delay in marking as answer.
    However, it would be better if you could provide me Javascript code or Plugin as i am from a non IT Background.
    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard