What is rule availability in Pega?

文章详细介绍了Pega系统中规则的可用性,包括Available、NotAvailable、Withdrawn、Blocked和Final五种状态,以及它们在规则解析和版本管理中的作用。通过实例展示了如何配置和测试这些规则状态,特别强调了在开发环境中如何使用这些功能来管理规则的运行和调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

What is rule availability in Pega?

Create Time: 2017/06/26
Type: Application Structure

Introduction

In this post we will see more in details about the rule availability.

  • Let me start this post with a story.
  • I invited my close friends for a party in a whatsapp group. I asked them to send a confirmation reply.

Friend 1: I am always ready to attend the party (Bestie 😄)

Friend 2: I am not available for the party.

Friend 3: I won’t come for the party. I will not allow my friends too !!

Friend 4: I am ready to come for the party, but I got a family function blocking that day

Friend 5: I am coming. This is my decision and no one can change it.

http://myknowpega.com/wp-content/uploads/2017/06/NP-4.png

So sad. I got positive response from only two people. I cancelled the party and started writing a new post for you guys. ‘Rule availability’

  • I find there are many similarities between my friends availability and rule availability.

I asked 5 rules to run

Rule 1: I will run for you (Available)

Rule 2: I will not run for you. (Not available)

Rule 3: I will not run for you, I will not allow rules in my lower version to run. (Withdrawn)

Rule 4: I can run for you, but I am blocked (Blocked)

Rule 5: I will run for you. You cannot update me (can be updated in same open version)

What is rule availability?

  • Rule availability helps in managing rules. They can determine, if the rule is eligible to run or not. They can also determine the availability of rule in lower versions.
  • In the rule form, you can configure the rule availability.

Why do you use rule availability?

Scenario: there may be some scenario, where don’t want a particular rule to run in the application. You can use the availability feature in the rule form to make the rule not available for rule resolution.

  • We know, Pega use different rules to support a business process.

For example – when you create a new work item, there are many rules involved to complete the task like flows, activities, when etc. Some rules in the framework can be overridden in the Implementation layer.

  • Rule resolution, helps in picking the right rule.

What are the types of rule availability in Pega?

  1. Available
  2. Not Available
  3. Withdrawn
  4. Blocked
  5. Final

We will explore all the possible by rule availability scenarios with examples.

What are the pre-requisites to test rule availability?

You can test using any rule. In this tutorial I am going to guide you through activity rules.

Create 2 new activities.

  1. ParentAvailable
  2. ChildAvailable

Parent activity – Use ‘Call’ keyword and call child activity from parent activity.

http://myknowpega.com/wp-content/uploads/2017/06/Av1.png

Child activity – For testing purpose, use a property-set to set pyLabel – “Child rule is available”

http://myknowpega.com/wp-content/uploads/2017/06/AV6.png

  • Create a new section, and include some fields. Have a button control. In the button, On click event add an action set to call the parent activity.

http://myknowpega.com/wp-content/uploads/2017/06/AV2.png

How do you configure rule availability?

http://myknowpega.com/wp-content/uploads/2017/06/AV3.png

You can use Live UI and check the property involved in holding the availability value in rule form. – ‘pyRuleAvailable’.

http://myknowpega.com/wp-content/uploads/2017/06/AV4.png

You can see the property ‘pyRuleAvailable’ in the rule class contains the availability value.

How do you use different availablity options?

a) Available – As the name suggests, the rule is always available to run.

Here I have configured both the activities, parent & child activities ‘Available’.

This is very simple to test. The rule will run anyways

Step 1: Open the section in user portal.

http://myknowpega.com/wp-content/uploads/2017/06/AV5.png

Step 2: Start the tracer & click on the check availability button.

http://myknowpega.com/wp-content/uploads/2017/06/AV7.png

you can see the child activity ran. It is available

I think its enough for rule available

b) Not Available

  • Using this option, you can make a rule not available in particular version.

For example – Say you have a rule in 2 versions : 01-01-01 & 01-01-02. Default rule resolution always picks the highest version. In our case 01-01-02.

Now, here if you want your rule in 01-01-01 to run, then you can make the rule availability in 01-01-02 to ‘No’

Note: You always use this in development environment. There is no use in moving a rule to higher environment with rule availablity set to ‘No’. You can just delete it right

So when you actually use?

  • In development environment, say you have a rule in 01-01-01.
  • You saved the rule in higher version 01-01-02 and did some drastic changes. When you test the rule, it throws error.
  • You need to check, how it worked previously

So instead of deleting the rule in 01-01-02, you can make the rule availability to ‘No’.

The rule resolution invalidates the rule with availability set to ‘Not Available’, so it runs the rule in 01-01-01.

We will test and check how this works.

Step 1: Save As the child activity in 01-01-02 and set pyLabel to ‘Availability No checking’.

http://myknowpega.com/wp-content/uploads/2017/06/AV8.png

Step 2: Click on the button. As of now keep it available and use tracer to check the value.

http://myknowpega.com/wp-content/uploads/2017/06/AV9.png

You can see ChildAvailable in MyKnowPega 01-01-02 gets picked and pyLabel is ‘Availability No checking’

Step 3: Now update the availability in 01-01-02 to ‘Not Available’.

http://myknowpega.com/wp-content/uploads/2017/06/AV10.png

Step 4: Lets check the same in user portal again. trace it.

http://myknowpega.com/wp-content/uploads/2017/06/AV11.png

See, now you can see the rule in 01-01-01 is picked.

You can use this for testing in development environment

c) Withdrawn

  • Selection this option makes the rule in the current version and previous versions in the same ruleset, withdrawn from the rule resolution. It means rule resolution, invalidates the withdrawn rule and its other lower versions in the same ruleset.

For example – You have your rule in MyKnowPega 01-01-01 version and updated the rule in MyKnowPega 01-01-02 version. When you withdraw the rule in 01-01-02 version, then the rule resolution never pick the rule in both 01-01-02 & underlying versions – 01-01-01.

What are the other scenarios , you withdraw a rule?

  • You override an pega OOTB rule in your application ruleset. You started implementing your own requirement. In later release, Pega provides the same feature in their OOTB activity, So you no longer required the overridden activity in your application ruleset.

What will you do here?

You cannot delete the rule, since the rule is packed and moved to higher environment.

All you can do is save as the rule in higher application ruleset and withdraw the rule. You can move the withdrawn rule to higher environment. So it invalidates rule in lower versions too

  • You have a rule say – ‘discount flow’ in ‘OIKGGB-MyKnowPega-Work’ .
  • You Overridden the flow in ‘OIKGGB-MyKnowPega-Work-AmazonSales’ class for Amazon sales case.
  • After some particular release, You included all the Amazon sales discount process in the ‘OIKGGB-MyKnowPega-Work’ class generic flow. So now, no use in having a specialized version in Amazon sales class.

What will you do here?

You can withdraw the rule you specified in the ‘OIKGGB-MyKnowPega-Work-AmazonSales’ class. So rule resolution picks the rule from ‘OIKGGB-MyKnowPega-Work’ class.

Let’s test the withdrawn rules

Step 1: Create a new copy of the ChildAvailable rule in Application Integration ruleset.

http://myknowpega.com/wp-content/uploads/2017/06/av12.png

Note: But this MyKnowPegaInt ruleset always comes under MyKnowPega (Implementation ruleset) in ruleset hierarchy. Rule resolution always picks the rule in higher ruleset in the hierarchy. In our case – MyKnowPega

Step 2: let’s test using tracer.

http://myknowpega.com/wp-content/uploads/2017/06/AV13.png

You can see the rule in MyKnowPega 01-01-02 is picked.

Step 3: Now let’s withdraw the rule from MyKnowPega 01-01-02 version.

http://myknowpega.com/wp-content/uploads/2017/06/AV14.png

Step 4: Let’ check in the user portal using tracer.

http://myknowpega.com/wp-content/uploads/2017/06/AV15.png

You can see the rule is picked from MyKnowPegaInt ruleset

What are the differences between ‘Not Available’ and ‘Withdrawn’ rule?

  • ‘Not Available’ invalidates the rule only in the current version, where as the ‘Withdrawn’ invalidates the rule in the current version and lower versions in the same ruleset.
  • Mostly we use ‘Not Available’ only in development environment and don’t promote those to higher environments, where as the ‘Withdrawn’ rules can be moved to higher environment

d) Blocked

  • Selecting this option will not invalidate the blocked rule for rule resolution. Still the blocked rule is right candidate and if the rule gets picked by rule resolution, then the process returns not found.

When do you block a rule?

  • Say for example, Amazon needs to stop their online electronics sales for a particular country. It can be resumed in later point of time. In this case you can block the respective rules. The rules just throw the error to end user.
  • In development environment, If you didn’t complete the entire development, you can block the corresponding rule till then.

Let’ test a blocked rule.

Step 1: Save As the child activity and make the availability to ‘Blocked’.

http://myknowpega.com/wp-content/uploads/2017/06/AV16.png

Step 2: Check in the user portal. Trace it.

http://myknowpega.com/wp-content/uploads/2017/06/AV17.png

You can see the exception thrown. Since we are testing it using button call, it never stops flow processing(kind of local action). So let’s test by using the activity in flow action post processing activity.

Step 3: Open the flowaction – add the ‘ParentAvailable’ activity in Post-processing activity.

http://myknowpega.com/wp-content/uploads/2017/06/AV18.png

step 4: Now submit the flowaction in user portal.

http://myknowpega.com/wp-content/uploads/2017/06/AV19.png

You can see the error thrown. the process is blocked

e) Final

  • On Selecting this option, you are making a rule as final rule. You cannot override a final rule in another ruleset.
  • When you try save as the rule, you will get an error.

Note: You can save as the Final rule in the same ruleset in higher versions

When do you make a rule final?

  • In my point of view, Pega introduced the ‘Final’ availability to restrict developers updating the core designer studio engine rules.
  • If you are sure that the rule cannot be reused in any other rulesets. It means you will never Save As the same rule to use in other rulesets ( We use it rarely )

For example: You can check underlying sections in any rule form header. Pega makes the sections, rules final, because they don’t want us to update those in rules in our application rulesets.

http://myknowpega.com/wp-content/uploads/2017/06/AV20.png

Let’ test the final rule availability

Step 1: Open any final rule OOTB rule.

Section – RuleFormHeader

Step 2: Try Save As the rule in your application ruleset.

http://myknowpega.com/wp-content/uploads/2017/06/AV28.png

It means you cannot copy a Final rule in different rulesets

We can try copying a final rule in same ruleset higher version

Step 1: Open the child activity and set the availability to ‘Final’.

http://myknowpega.com/wp-content/uploads/2017/06/AV26.png

Step 2: Now try Save As in the next ruleset version 01-01-02.

http://myknowpega.com/wp-content/uploads/2017/06/AV27.png

You are able to make a copy only in the same ruleset higher versions

What are the things to remember?

  • Rule availability: Available – Rule is always ready to run
  • Rule availability: Not available – Rule is not available to run. Rule resolution invalidates the rule.
  • Rule availability: Withdrawn – The withdrawn rule as well as the lower versions in the same ruleset are not available to run
  • Rule availability: Blocked – the blocked rule throws exception when it runs. Rule resolution don’t invalidate the rule
  • Rule availability: Final – You cannot specialize the Final rule in other rulesets. You can Save As only in higher versions in same ruleset.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值