Wednesday, November 28, 2018

Business rule can trigger custom Javascript

Recently I have discovered on feature which is documented properly, but it can be very useful.
Inside a Business rule, you can also use action called "Run script".
If you go to business rules and try to create one, you will most likely not see this option. Here is the trick.

This action is only available on the forms connected to the Task flows (accessible from mobile interface and the new unified interface).
So you need to create a new Task flow or open existing one. The go to Business rules.
Create a new Business rule there. You will notice, that this Business rule is only valid on the form which name is the same as the Task flow. It cannot be modified.
Now you can insert the Run script  component. Simple script can be inserted in the text field.

I would suggest putting only simple script here, as it is not stored as a Web resource and cannot be managed well.

I am using it for simple logic which must be implemented in the Task flow. I can access fields, change their properties and so on. But basically, any code will run. I did not hit any limit in terms of max number of characters.

I will keep investigating it and post any updates.


3 comments:

  1. Fantastic blog you have here. You’ll discover me looking at your stuff often. Saved! website design companies

    ReplyDelete
  2. Good work. Thanks for the info. Will try my hands on it.

    ReplyDelete
  3. Do you have a sample of a script so I can try it out?

    ReplyDelete