Menu

Complete Link Table between Order (OrderRequest) and Contract (CustomerContract)

Fabian
2020-06-02
2020-11-25
  • Fabian

    Fabian - 2020-06-02

    Good day community,

    I have a question releated to Link Tables in iTop. We're using the newest version (2.7).
    We have the wish that there's a Link Table between the the classes Contract and Order, like the integrated «link table» with the name «Link Contact / Contract (lnkContactToContract)».

    Is it possible to create a custom link table? Is there a way to do (best practice) - for example to create a new extension? Are there any examples online for this specific topic or any documentations?

    Thanks for the support!

    Regards

     
  • Molkobain

    Molkobain - 2020-06-02

    Hello Fabian,

    You can totally add a link between 2 objects, it's what make the beauty of iTop! 😍

    The best practice is to do so by creating your own extension which will alter the XML datamodel to add the link table ("indirect linkedset" in iTop vocab). Also, as you will alter an XML node brought by another extension, make sure to add a dependency to this module, otherwise it might not compile correctly.

    • Check here for resources on how to make your own extension.
    • Here for the XML structure of the AttributeLinkedSetIndirect
    • You can check this extension of @jbostoen which does plenty but take a look at the functionalcis_list attribute of the Certificate class in the datamodel.jb-certificate.xml file.

    Let us know if you are having some trouble while making it :)

    Hope this helps,
    Guillaume

     
  • Fabian

    Fabian - 2020-06-03

    Hi Guillaume

    Thanks for this great feedback! I was able to create the indirect linkedset between the Order and the Contract class - very cool and nice feature. Also the extension from jbostoen is amazing.

    At least, in iTop in when I go to the «Data Model» section everything looks fine :)
    But if I go to the database and do a select statement on the new table:

    select * from lnkcontracttoorder
    

    The database (MySQL) give me an error, that the table «lnkcontacttoorder» is not existing.
    Did I forget something to declare / create in the extension?

    Here is my code:

        <class id="lnkContractToOrder" _delta="define">
          <parent>cmdbAbstractObject</parent>
          <properties>
            <category>bizmodel,searchable</category>
            <is_link>1</is_link>
            <abstract>false</abstract>
            <key_type>autoincrement</key_type>
            <db_table>lnkcontracttoorder</db_table>
            <db_key_field>id</db_key_field>
            <db_final_class_field/>
            <naming>
              <format>%1$s</format>
                <attributes>
                  <attribute id="order_id_friendlyname"/>
                  <attribute id="contract_id_friendlyname"/>
              </attributes>
            </naming>
            <display_template></display_template>
            <icon></icon>
            <reconciliation>
              <attributes>
                <attribute id="order_id"/>
                <attribute id="contract_id"/>
              </attributes>
            </reconciliation>
            </properties>
            <fields>
              <field id="order_id" xsi:type="AttributeExternalKey" _delta="define">
                <sql>order_id</sql>
                <is_null_allowed>true</is_null_allowed>
                <on_target_delete>DEL_MANUAL</on_target_delete>
                <target_class>Order</target_class>
              </field>
              <field id="contract_id" xsi:type="AttributeExternalKey" _delta="define">
                <sql>contract_id</sql>
                <is_null_allowed>true</is_null_allowed>
                <on_target_delete>DEL_MANUAL</on_target_delete>
                <target_class>Contract</target_class>
              </field>
            </fields>
            <methods></methods>
            <presentation>
              <details>
                <items>
                  <item id="order_id">
                    <rank>10</rank>
                  </item>
                  <item id="contract_id">
                    <rank>20</rank>
                  </item>
                </items>
              </details>
              <search>
                <items>
                  <item id="order_id">
                    <rank>10</rank>
                  </item>
                  <item id="contract_id">
                    <rank>20</rank>
                  </item>
                </items>
              </search>
              <list>
                <items>
                  <item id="order_id">
                   <rank>10</rank>
                  </item>
                  <item id="contract_id">
                    <rank>20</rank>
                  </item>
                </items>
              </list>
            </presentation>
            <default_search></default_search>
        </class>
    
     

    Last edit: Fabian 2020-06-03
  • Molkobain

    Molkobain - 2020-06-03

    Hello Fabian,

    Glad to hear you managed to make the link!

    Did you make your own extension or did you tweak Jeffrey's?
    In your config file, did you set a table prefix for the database?

    Sharing the whole extension could help o troubleshoot.

    Guillaume

     
  • Fabian

    Fabian - 2020-06-03

    Hi Guillaume

    Thanks for the support.

    I did the changes on an extension created by our company. You can find our extension in the attachments.

    Regards
    Fabian

     

    Last edit: Fabian 2020-06-04
    • Fabian

      Fabian - 2020-06-05

      Good day Guillaume

      I did a lot of tests to reproduce the error, but still there's no table in the MySQL-Database.
      Did you find something strange on the code or is there something more to do?

      You can find the actual code from the extension in the attachment.

      Thank you very much for the support.

      Regards Fabian

       
  • Fabian

    Fabian - 2020-06-15

    Hi Guillaume

    Did you find something strange or wrong in my question and the attached code? The generation of the database-table is not working automatically on our iTop instance.

    What's your suggestion to this topic? Should we create the table manually direct on the database with the two foreign-keys?

    Have a pleasant evening.

    Thanks for the support!
    Fabian

     
    • Kirk Thompson

      Kirk Thompson - 2020-10-08

      Dear Fabian.

      Sorry for hitting an old thread but I am having the same sort of problem and was wondering if you ever could get the table(Class) created via the toolkit..?

      Thnx.
      -K

       
  • Molkobain

    Molkobain - 2020-06-18

    Hello Fabian,

    In the datamodel viewer, if you open the "Order" class and go to the "Related classes" tab, you will see that the "lnkContractToOrder" link doesn't appear like the others.

    When you open the datamodel.xxx.xml file of your extension (thanks for posting it btw), we can see that in the "Order" class, you commented the "contract_list" field with the "lnkContractToOrder" table and replaced it a few lines lower with another "contract_list" field with a "lnkCertificateToFunctionalCI" table. That's the problem.

    Remove the second "contract_list" field, uncomment the first one and it will be ok. (That being said, the field isn't in the "details" presentation, so you won't see the tab. You might want to add it)

    Hope this helps,
    Guillaume

     
  • combes pierre

    combes pierre - 2020-11-06

    Hello,
    I created an lnk between Location to Provider Contracts, but I don't see the tab Provider Contracts in Location screen .I don't have any error during the installation process

    Here is the code:

    <itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
    <classes>
    <class id="user-content-lnkLocationtoContract" _delta="force">
    <parent>cmdbAbstractObject</parent>
    <properties>
    <is_link>1</is_link>
    <category>bizmodel</category>
    <abstract>false</abstract>
    <key_type>autoincrement</key_type>
    <db_table>lnklocationtocontract</db_table>
    <db_key_field>id</db_key_field>
    <db_final_class_field>
    <naming>
    <attributes>
    <attribute id="user-content-location_id">
    <attribute id="user-content-providercontract_id">
    </attribute></attribute></attributes>
    </naming>
    <display_template>
    <icon>
    <reconciliation>
    <attributes>
    <attribute id="user-content-location_id">
    <attribute id="user-content-providercontract_id">
    </attribute></attribute></attributes>
    </reconciliation>
    </icon></display_template></db_final_class_field></properties>
    <fields>
    <field id="user-content-location_id" xsi:type="AttributeExternalKey">
    <sql>location_id</sql>
    <target_class>Location</target_class>
    <is_null_allowed>false</is_null_allowed>
    <on_target_delete>DEL_AUTO</on_target_delete>
    </field>
    <field id="user-content-location_name" xsi:type="AttributeExternalField">
    <extkey_attcode>location_id</extkey_attcode>
    <target_attcode>name</target_attcode>
    </field>
    <field id="user-content-providercontract_id" xsi:type="AttributeExternalKey">
    <sql>providercontract_id</sql>
    <target_class>ProviderContract</target_class>
    <is_null_allowed>false</is_null_allowed>
    <on_target_delete>DEL_AUTO</on_target_delete>
    </field>
    <field id="user-content-providercontract_name" xsi:type="AttributeExternalField">
    <extkey_attcode>providercontract_id</extkey_attcode>
    <target_attcode>name</target_attcode>
    </field>
    </fields>
    <methods>
    <presentation>
    </presentation></methods></class></classes></itop_design>


    <items>
    <item id="user-content-location_id">
    <rank>10</rank>
    </item>
    <item id="user-content-providercontract_id">
    <rank>20</rank>
    </item>
    </items>

    <search>
    <items>

        <item id="location_id">
             <rank>10</rank>
        </item>
          <item id="providercontract_id">
             <rank>20</rank>
          </item>
         </items>
        </search>
        <list>
        <items>
          <item id="location_id">
             <rank>10</rank>
        </item>
          <item id="providercontract_id">
             <rank>20</rank>
          </item>
        </items>
        </list>
    </presentation>
    </class>
    


    <profiles>
    </profiles>

    </items></search>
     
  • Pierre Goiffon

    Pierre Goiffon - 2020-11-24

    Hello,
    I've just installed your XML (by the way, prefer add the content as an attachment if it's longer than a few lines of code), and I can see the object is created through the data model viewer.
    But indeed no extra tab in the ProviderContract object...
    For this tab to appear, you'll need to add in each Location and ProviderContract classes a new AttributeLinkedSetIndirect. See how it's done for AttributeLinkedSetIndirect for example...

     
  • combes pierre

    combes pierre - 2020-11-25

    Hello,
    thank you I will test

     

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.