Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

pyEditElement created on checking out Decision data rule



Checking out a Decision data rule and saving it to a new version each time, creates a pyEditElement section. 

Error Messages

Not Applicable 

Steps to Reproduce

  1. Create a Decision data.
  2. Create an associated pyEditElement section.
  3. Save the Decision data rule to a different ruleset version.

Root Cause

A defect in Pegasystems’ code or rules.



Running the Cleanup utility is a stop-gap solution.

In situations where the utility does not exist in a given release, it is recommended to perform either of the following local-changes:
  • Create the Cleanup utility locally and use it.
  • Upgrade to the latest platform version that has the productized version of the utility out-of-the-box.

Refer to the following Java code to facilitate the local solution.

Copy the code either to a local function on the environment or to a Java step of a local activity.

For more information on how to use the Cleanup utility refer to:

Java Code:

------------------------ Start Java code ----------------------

//prepare the list of decision data and edit element sections
String[] fullyQualifiedDDNameList = decisionDataWithClassNames.split(",");

boolean skipDelete = false;

//prepare when rule keys to check whether or not to delete the pyEditElement section
StringMap blockKeys = new HashStringMap();
blockKeys.putString("pxObjClass", "Rule-Obj-When");
blockKeys.putString("pyClassName", "@baseclass");
blockKeys.putString("pyBlockName", "pySkipDeleteEditElement");

//process for every decision data
for(int i=0; i<fullyQualifiedDDNameList.length; i++){
  String ddName = fullyQualifiedDDNameList[i];
  String[] ddNameParts = ddName.split(":");
  StringMap keys = new HashStringMap();
  keys.putString("pxObjClass", "Rule-Decision-DecisionParameters");
  keys.putString("pyClassName", ddNameParts[0]);
  keys.putString("pyPurpose", ddNameParts[1]);
  //open the decision data record from the database
  ClipboardPage ddRule = null;
    ddRule = tools.getDatabase().open(keys, false);
  catch(DatabaseException e){
    oLog.error("There was a problem accessing the database. "+e);
    return false;
  String pyDPCircumstanceValue = "";
  String pySelectedClass = "";
  String pyPurpose = "";
  String circumstanceValue = "";
    pyDPCircumstanceValue = ddRule.getString("pyDPCircumstanceValue");
    pySelectedClass = ddRule.getString("pySelectedClass");
    pyPurpose = ddRule.getString("pyPurpose");
    circumstanceValue = pyPurpose.length() > 30 ? pyPurpose.substring(0,30) + "!" : pyPurpose + "!";
      oLog.debug("pyEditElement with circusmstance value starting "+circumstanceValue+" will be deleted");
    //formulate the query to fetch all instances of the pyEditElement section for this decision data rule
    String query = "select pzInsKey as \"pzInsKey\", pyRuleSet as \"pyRuleSet\", pyRuleSetVersion as \"pyRuleSetVersion\", pyCircumstanceVal as \"pyCircumstanceVal\" from {Class:Rule-HTML-Section} where pyCircumstanceProp = '.pyDPCircumstanceValue' and pyCircumstanceVal != '" + pyDPCircumstanceValue + "' and pyCircumstanceVal LIKE '"+circumstanceValue+"%' and pxObjClass = 'Rule-HTML-Section' and pyStreamName = 'pyEditElement' and pyClassName = '"+pySelectedClass+"'";
    ClipboardPage cp = tools.createPage("Code-Pega-List", "ResultsPage");
    cp.putString("pyObjClass", "Rule-HTML-Section");
    cp.putString("pyMaxRecords", "0");
      tools.getDatabase().executeRDB(query, cp);
      ClipboardProperty results = cp.getProperty(".pxResults");
        oLog.debug("Number of old circumstanced instances of pyEditElement found for decision data "+ddName+" is "+results.size());
      for(Iterator iterator=results.iterator(); iterator.hasNext();){
        ClipboardProperty rp = (ClipboardProperty);
        ClipboardPage currentResult = rp.getPageValue();
        String insKey = rp.getStringValue("pzInsKey");
        PRStackFrame frame = ((PegaAPI)tools).pushStackFrame("when", null, currentResult, true, false);
              skipDelete = tools.evaluateWhen(blockKeys);
            ((PegaAPI)tools).popStackFrame(frame, false);
          //delete the old circumstanced version of the pyEditElement section
          tools.getDatabase().delete(insKey, false, true, true, null);
            oLog.debug("pyEditElement with circusmstance value "+rp.getStringValue("pyCircumstanceVal")+" was deleted from ruleset "+rp.getStringValue("pyRuleSet")+" "+rp.getStringValue("pyRuleSetVersion"));
    catch(Exception e){
      oLog.error("Exception while deleting the pyEditElement sections for decision data "+pyPurpose+". "+e);
      return false;
    oLog.error("Decision data record "+ddName+" was not found.");
    return false;

return true;

------------------------------------ End of java code ------------------------------

Additionally, create the following When rule (if not present already) with a custom name (not with py) in the Application ruleset and mention the name in the Java code.

When: EXTENSION: Skip delete edit element [Available]

CL @baseclass
ID: pySkipDeleteEditElement
RS: PegaMKT-Engine:08-04-01

Navigate to the Advanced tab.

Set 1 to @startsWith(.pyRuleSet,"Pega-")
Set 2 to @startsWith(.pyRuleSet, "PegaMKT-")
Set the Logic String to 1 | | 2
Select the 'Display property labels' checkbox.

All properties are not supported in the When rule. Only columns that are retrieved by the SQL query (in the Java code) can be used in the When rule.

This feature is implemented in Pega Platform 8.4 and later.

Published December 2, 2021

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us