| Uzair Iftikhar

How to use JavaScript in a business rule to set field values or control field behavior

To involve JavaScript in a business rule to set field values or control field conduct in a model-driven application, you can follow these means:

Step 1

Open the business rule proofreader for the structure where you need to utilize JavaScript. You can get to the business rule proofreader from the structure originator by tapping the "Business Rules" button in the lace.

Step 2

Click the "New" button to make another business rule.

Step 3

In the "Name" field, enter an illustrative name for your business rule.

Step 4

In the "Conditions" segment, determine the circumstances under which the business rule ought to be assessed. You can utilize the "Add" button to add extra circumstances.

Step 5

In the "Activities" segment, click the "Add" button to add another activity.

Step 6

In the "Activity" field, select "Set field esteem" from the dropdown list.

Step 7

In the "Field" field, select your desired field to set the incentive for.

Step 8

In the "Worth" field, enter your desired worth to set for the field. You can utilize JavaScript articulations to powerfully work out the worth in light of other field values or factors.


Step 9

Click the "Save" button to save your business rule.

Your business rule will presently be executed at whatever point the predetermined circumstances are met, setting the worth of the predefined field to the worth you indicated.



Type

JavaScript

Command Name

Edit

Phase

After

Script

var d = [OrderDate];

if (this.dataView().get_isEditing() && d != null) {

d.setDate(d.getUTCDate() + 7);

d.setHours(0);

[OrderDate] = d;

}

Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.



About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.


More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting