Menu

Show new text attribute from organization on user request

2025-07-24
7 days ago
  • Niclas Eriksson

    Niclas Eriksson - 2025-07-24

    I'm trying to add some additional information to an organization which I want to show on all user requests/tickets for that organization. I've created an extension that on the organization adds:
    <field id="org_debit_notes" xsi:type="AttributeText"></field>

    And this works fine, I can view and edit that text on the organization page.

    But now I want to show that text on the user request page as information for all requests linked to that organization. I've tried this:

    <class id="UserRequest" _delta="must_exist">
      <presentation>
        <details _delta="must_exist">
          <items>
            <item id="org_info_fieldset" xsi:type="FieldSet">
              <label>Organization Info</label>
              <items>
                <item id="org_debit_notes_display" xsi:type="StaticText">
                  <label>Org Debit Notes</label>
                  <value><![CDATA[
                    $this->Get('org_id') ? $this->Get('org_id')->Get('org_debit_notes') : '—
                  ]]></value>
                </item>
              </items>
            </item>
          </items>
        </details>
      </presentation>
    </class>
    

    And the deployment works but as soon as I try to open a request I just get an error:
    iTop: An error occurred, check server error log for more information.

    And the apache error is:
    PHP Warning: Undefined array key "org_debit_notes_display" in /var/www/html/itop/core/metamodel.class.php on line 1478

    Does anyone know how this should be done?

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2025-07-24

    Any chance you generated this with an AI tool? This seems completely invalid XML for iTop.

    You'd want to add an AttributeExternalField pointing to your org_debit_notes field of your organization; and add it properly in the presentation of the user request.

     
    • Niclas Eriksson

      Niclas Eriksson - 2025-07-24

      Hi Jeffrey, yes I did, but it looked similar to other xml's I have for other purposes (this is not the complete code) but you're probably completly right in that something is off and I'm doing it wrong.

      OK great tip, AttributeExternalField is the way I should go with then.. I'll give it a try to figure it out. Thanks for pointing out the direction :)

       
  • Niclas Eriksson

    Niclas Eriksson - 2025-07-24

    I did this and now it works:

    <class id="UserRequest" _delta="must_exist">
                        <fields>
                          <field id="org_debit_notes" xsi:type="AttributeExternalField">
                            <description>Display debit notes from the related organization</description>
                            <target_class>Organization</target_class>
                            <extkey_attcode>org_id</extkey_attcode>
                            <target_attcode>org_debit_notes</target_attcode>
                          </field>
                        </fields>
    
                      <presentation>
                        <details>
                          <items>
                            <item id="col:col1" _delta="must_exist">
                              <items>
                                <item id="fieldset:Ticket:moreinfo" _delta="must_exist">
                                  <items>
                                    <item id="org_debit_notes">
                                    <label>Debit info</label>
                                      <rank>60</rank>
                                    </item>
                                  </items>
                                </item>
                              </items>
                            </item>
                          </items>
                        </details>
                      </presentation>
    
                      </class>
    

    The on ly problem now is that the text displayed is not the Label I have in the code, but seems to be rendered from the class and attribute name:

    "Organization->Organization Debit Notes"

     
    👍
    1
  • Niclas Eriksson

    Niclas Eriksson - 7 days ago

    Fixed by adding entries in the dict file, I forgot that I had one HAHA...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.