You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在IBM Rational DOORS中仅为指定需求的文本前置需求ID(括号形式)——程序化实现方案咨询

How to Programmatically Prepend ID to Text When "Is Requirement?" is TRUE in IBM Rational DOORS

Absolutely, this is fully achievable using IBM Rational DOORS DXL scripting—you’ve got two solid options depending on whether you want to permanently modify the Text attribute or dynamically display the modified content without altering your original data. Let’s break this down:

Option 1: Batch Update the Text Attribute (Permanent Change)

This script will iterate through all objects in your open module, check if "Is Requirement?" is TRUE, and prepend [ID] to the Text content (only if it’s not already there, to avoid duplicates).

The DXL Script

// Batch update Text attribute for requirement objects
Module targetModule = current
if (null targetModule) {
    print "Error: Please open a module first before running this script!\n"
    exit
}

// Ensure the module is locked for editing
if (!isLocked(targetModule)) {
    lock(targetModule)
}

Object currentObj
for currentObj in targetModule do {
    // Check if the object is marked as a requirement
    if (currentObj."Is Requirement?" == TRUE) {
        string objID = identifier(currentObj)
        string originalText = currentObj."Text"
        
        // Skip if the ID is already prepended to avoid duplicates
        if (originalText !~ "^\\[" objID "\\]") {
            currentObj."Text" = "[" objID "] " originalText
        }
    }
}

// Save the changes
save(targetModule)
print "Success! Updated all qualifying requirement objects.\n"

How to Execute:

  1. Open the module you want to modify in DOORS.
  2. Go to Tools > Edit > DXL Editor to open the script editor.
  3. Paste the code above into the editor.
  4. Click the Run button (or press F5) to execute the script.
  5. The script will automatically lock the module (if needed), update eligible objects, and save your changes.

Option 2: Use a DXL Computed Attribute (Dynamic, Non-Permanent)

If you don’t want to alter your original Text data, this is the safer approach. We’ll create a new computed attribute that dynamically displays the Text with the [ID] prepended only when "Is Requirement?" is TRUE.

Step-by-Step Setup:

  1. Open your target module and go to Tools > Attributes > Edit Attributes.
  2. Click the New button to create a new attribute.
  3. Configure the attribute:
    • Name: Choose something descriptive like Display Text with ID
    • Type: Select DXL from the dropdown menu
    • DXL Field: Paste this code:
      string outputText = obj."Text"
      if (obj."Is Requirement?" == TRUE) {
          outputText = "[" identifier(obj) "] " outputText
      }
      outputText
      
  4. Click OK to save the attribute.
  5. Add this new attribute to your module’s column view (right-click column headers > Insert Column > select your new attribute).

Now, whenever you view the module, this computed attribute will show the modified text for requirements, while your original Text attribute remains untouched.

Key Questions Answered:

  • Do I need an additional DXL attribute? Only if you choose the dynamic computed attribute approach (Option 2). For permanent updates (Option 1), you don’t need new attributes—we modify the existing Text directly.
  • Where do I put the code?
    • For Option 1: Paste the script into the DOORS DXL Editor and run it.
    • For Option 2: Paste the code directly into the DXL field when creating the new computed attribute.

Pro Tip

Before running any batch modification script (Option 1), it’s always a good idea to make a backup of your module to avoid accidental data loss.

内容的提问来源于stack exchange,提问作者Bijan Sanchez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 23:19:10