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 / Can Business Rule run ...
Power Apps
Answered

Can Business Rule run after formload ?

(0) ShareShare
ReportReport
Posted on by 945

Hello everyone,

 

Can Business Rule applied or run after form load ? So I have a needs whereby, my field will only set to be mandatory, when the record is saved on the 1st time. For example : I'm creating new record, in one of the field lets say "Description", is not mandatory, user can save this new record. But after 1st saved, I want this Description to be mandatory. Problem is I have a Javascript to make an autosaved at first time the form load.

 

In my head, I would think like this :

  1. Had 1 business rule to check some field, I have 1 field which is an autonumber, which will have value when it's saved.
  2. So when this field is contain data, my business rule is Set Business Required this Description, if not contain data, don't make field Description as Business Required.

Is this make sense ?

Well, I tried like that, but it's not working, because it's looks like when it is saving (my java script to auto save running) then in that instance, the field "Description" is mandatory, so it is already return error.

 

Kindly advice whether it's possible to make the business rule run after form load, so my data will be saved first then displayed fully on the screen, then right after that my field become mandatory. So only at the 2nd time and after, when user click save, it will throw message that field is empty.

 

Thanks

I have the same question (0)
  • Ram Prakash Duraisamy Profile Picture
    5,714 Super User 2026 Season 1 on at

    Hey @Axal,

     

    Please try this logic in Business Rule

     

    Condition :

     

    If CREATEDON contains Data

    Set Description field as Mandatory

    Else Description field not Mandatory

     

    Createdon Field will only store values if record gets created.

     

    Please mark as Answer if it is helpful and provide Kudos

     

    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA

    Blog : https://microsoftcrmtechie.blogspot.com

  • Axal Profile Picture
    945 on at

    Hi @rampprakash 

     

    Unfortunately, it is not working. With that rule, when my form load, it already give me error saying "Description" is empty.

     

    The form not shown first.

     

     

    Thanks,

     

  • Ram Prakash Duraisamy Profile Picture
    5,714 Super User 2026 Season 1 on at

    Hi @Axal,

     

    Can you please remove all your existing logic and check the Entity type to form and tray again.

  • Axal Profile Picture
    945 on at

    Hi @rampprakash ,

     

    I'm sorry, what should I check on the entity ? and what is entity type to form ?

    Thanks

  • Prakash4691 Profile Picture
    1,332 on at

    @Axal 

     

    I think you might be using 

    formContext.data.save(saveOptions), saveoption->savemode set to 70 to autosave using javascript.
     
    If you use above client API it runs asynchronously, that is why on onload your business rule triggers first and throwing an exception even before javascript executes.  
     
    To overcome the issue, deactivate business rule and handle everything using javascript.
     
    Including sample code below,
    function onload(executionContext) {
      var formContext = executionContext.getFormContext();
      if (formContext.ui.getFormType() == 2) {// check for form type it should run only on update and not on create
        var saveOptions = { saveMode: 70 };
        formContext.data.save(saveOptions).then(
          function (success) {
            formContext.getAttribute("cr5b9_jh").setRequiredLevel("required");// set required level
          },
          function (error) {
            console.log(error.message);
          }
        );
      }
    }
     
    If it answers your question, kindly give kudo and accept it as solution.
     
     
    Regards,
    Prakash
  • Ram Prakash Duraisamy Profile Picture
    5,714 Super User 2026 Season 1 on at

    Hi @Axal,

     

    Please find the sample screenshot for business Rule for your reference.

     

    rampprakash_1-1631250526263.png

    Please mark as Answer if it is helpful and provide Kudos

     

    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA

    Blog : https://microsoftcrmtechie.blogspot.com

     

  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @Axal,

    It's not working because business rules run on load (no guarantee of the execution order) and after a field referenced in the business rule changes. So what @rampprakash is suggesting won't work.  If you absolutely need logic after a save event then you'll need JavaScript to register a function on post save event: https://docs.microsoft.com/powerapps/developer/model-driven-apps/clientapi/reference/events/postsave 
    Hope this helps!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard