How to discard a rule from another operator

Yesterday, I ruined my Dev Studio access because I private-edited an OOTB rule (pzpega_ui_invoke.js). So I needed to discard it urgently or I would lose my operator and all my work. Unfortunately I no longer had access to the Dev Studio using my operator so I needed to do it from another operator. Here's how I accomplished it.

In short, I executed the following SQL (through a Connect SQL rule):

DELETE FROM {Class:RULE-FILE-TEXT} WHERE pyrulename='webwb pzpega_ui_invoke js' AND pyruleset='deivit@';

DELETE FROM {Class:Data-Rule-Summary} WHERE  pyrulename='webwb pzpega_ui_invoke js' AND pyruleset='deivit@';

The basics

First of all, we need to know where the checked-out rules are stored. When we check-out (or private-edit) a rule, a new record is created in its db table. So, for example, if we checked out the pyBlank section rule, a new record will be created in the pegarules.pr4_rule_section table.

We can obtain the name of the physical table associated with the rule type by clicking on the Test connection button in the definition of its class. So, for example, the section rules are of type Rule-HTML-Section whose associated physical table is pegarules.pr4_rule_section.

But that's not all, besides creating a new record in the rule type table, it also creates a new record in the table associated to the Data-Rule-Summary class, this table is the pegarules.pr4_rule_vw.

Instances of the Data-Rule-Summary that meet the condition .pyRuleSet=your.operator@ (our personal ruleset) are shown in the Checked out records popup.

Using SQL to discard a rule

So, in order to discard the rule, we have to delete these two records created when the rule was checked-out.

These steps can be carried out from any other operator.

Remove the rule table record

Create and execute an SQL Connect rule with the following SQL code in the Delete tab (modify it with the data of the rule you want to discard.)

DELETE FROM {Class:Rule-HTML-Section} WHERE pyrulename='pyBlank' AND pyruleset='deivit@';

A "Connect SQL" rule has three keys: Applies To, Package Name, and Label.

To execute a "Connect SQL" rule, use the RDB- methods in an activity. So, for example, if we want to delete records from a table, use the RDB-Delete method.

Also, note that the parameters of this method refer to the key parts of the "Connect SQL" with different names: Class Name (Applies To), RequestType (Label), and Access (Package Name)

Remove the Data-Rule-Summary record

Create and execute an SQL Connect rule with the following SQL code in the Delete tab (modify it with the data of the rule you want to discard.)

DELETE FROM {Class:Data-Rule-Summary} WHERE  pyrulename='pyBlank' AND pyruleset='deivit@';

Test it!

Download this component, add it to your application, and execute the Work-.DemoDiscardBySQL flow to see it in action.

References

Comments