Update class_structure with AML?

Hi Everyone,

I'm trying to add new classes to the class_structure of the Part ItemType with AML, but the results are giving me an empty class_structure. 

What I tried is something like 

<AML>
<Item type="ItemType" action='edit' id = "xxx">
<class_structure>
<class id="xxx">
<class name="Component" id="xxx"/>
<class name="Assembly" id="xxx"/>
<class name="Material" id="xxx"/>
<class name="Software" id="xxx"/>
<class name="Phantom" id="xxx" />
<class  name="MBOM only Part" id="xxx"/>

<class  name="Cat" id="xxx"/>
</class>
</class_structure>
</Item>
</AML>

and the result is an empty class_structure.

-<Result>
-<Item type =" ItemType " typeId =" 450906E86E304F55A34B3C0D65C097EA " id =" 4F1AC04A2B484F3ABA4E20DB63808A88 " >
 <allow_private_permission>1</allow_private_permission>
 <auto_search>0</auto_search>
 <class_structure/>
.....
 
Any suggestions of how to correctly update the class_structure would be appreciated.
Kevin
Parents
  • Hi Kevin,

    It appears that the class_structure property on ItemType is a Text field. Here's what it looks like for the Part ItemType:

    I believe your issue is that you're treating the XML within the class structure as an extension of your AML, when in reality it's basically a long string within your class_structure property. I've created a basic ItemType with a modified class structure and exported it via the export tool. Here's how it looks: 

    <AML>
     <Item type="ItemType" id="49E6DF25B40944D2895243AB3C3D5D76" action="add">
      <allow_private_permission>1</allow_private_permission>
      <auto_search>0</auto_search>
      <class_structure><![CDATA[<class id="49E6DF25B40944D2895243AB3C3D5D76"><class id="79BD8D2734BA49569A685ECC60ECE851" name="test1"><class id="9FD75844F9A0438B891773350723A515" name="Test3" /></class><class id="9F0A06FA15E344C19CD7AAD0EC9F2F46" name="test3" /></class>]]></class_structure>
      <enforce_discovery>1</enforce_discovery>
      <hide_where_used>0</hide_where_used>
      <implementation_type>table</implementation_type>
      <instance_data>TEST</instance_data>
      <is_dependent>0</is_dependent>
      <is_relationship>0</is_relationship>
      <is_versionable>0</is_versionable>
      <label xml:lang="en">test</label>
      <label_plural xml:lang="en">test</label_plural>
      <revisions keyed_name="Default" type="Revision">7FE395DD8B9F4E1090756A34B733D75E</revisions>
      <show_parameters_tab>1</show_parameters_tab>
      <structure_view>tabs off</structure_view>
      <unlock_on_logout>0</unlock_on_logout>
      <use_src_access>0</use_src_access>
      <name>test</name>
      <Relationships>
       <Item type="View" id="5873C8FBA2664651AA4E7F728EBE10E1" action="add">
        <client>js</client>
        <related_id keyed_name="test" type="Form">99DCC4E32DEF4D27A5A6A7C15D48566A</related_id>
        <role keyed_name="World" type="Identity">
         <Item type="Identity" action="get" select="id">
          <name>World</name>
         </Item>
        </role>
        <show_ssvc>0</show_ssvc>
        <sort_order>128</sort_order>
        <source_id keyed_name="test" type="ItemType" name="test">49E6DF25B40944D2895243AB3C3D5D76</source_id>
        <type>default</type>
       </Item>
      </Relationships>
     </Item>
    </AML>

    It looks like the contents of the <Class_structure> tag are wrapped in a CDATA wrapper. your code should look like 

    <class_structure><![CDATA[ your class structure here ]]</class_structure>

    I'm curious why you're using AML for something like this? Generally going into the instance for a change like this would make more sense, where you can then export it and reimport if necessary.

    AJ

Reply
  • Hi Kevin,

    It appears that the class_structure property on ItemType is a Text field. Here's what it looks like for the Part ItemType:

    I believe your issue is that you're treating the XML within the class structure as an extension of your AML, when in reality it's basically a long string within your class_structure property. I've created a basic ItemType with a modified class structure and exported it via the export tool. Here's how it looks: 

    <AML>
     <Item type="ItemType" id="49E6DF25B40944D2895243AB3C3D5D76" action="add">
      <allow_private_permission>1</allow_private_permission>
      <auto_search>0</auto_search>
      <class_structure><![CDATA[<class id="49E6DF25B40944D2895243AB3C3D5D76"><class id="79BD8D2734BA49569A685ECC60ECE851" name="test1"><class id="9FD75844F9A0438B891773350723A515" name="Test3" /></class><class id="9F0A06FA15E344C19CD7AAD0EC9F2F46" name="test3" /></class>]]></class_structure>
      <enforce_discovery>1</enforce_discovery>
      <hide_where_used>0</hide_where_used>
      <implementation_type>table</implementation_type>
      <instance_data>TEST</instance_data>
      <is_dependent>0</is_dependent>
      <is_relationship>0</is_relationship>
      <is_versionable>0</is_versionable>
      <label xml:lang="en">test</label>
      <label_plural xml:lang="en">test</label_plural>
      <revisions keyed_name="Default" type="Revision">7FE395DD8B9F4E1090756A34B733D75E</revisions>
      <show_parameters_tab>1</show_parameters_tab>
      <structure_view>tabs off</structure_view>
      <unlock_on_logout>0</unlock_on_logout>
      <use_src_access>0</use_src_access>
      <name>test</name>
      <Relationships>
       <Item type="View" id="5873C8FBA2664651AA4E7F728EBE10E1" action="add">
        <client>js</client>
        <related_id keyed_name="test" type="Form">99DCC4E32DEF4D27A5A6A7C15D48566A</related_id>
        <role keyed_name="World" type="Identity">
         <Item type="Identity" action="get" select="id">
          <name>World</name>
         </Item>
        </role>
        <show_ssvc>0</show_ssvc>
        <sort_order>128</sort_order>
        <source_id keyed_name="test" type="ItemType" name="test">49E6DF25B40944D2895243AB3C3D5D76</source_id>
        <type>default</type>
       </Item>
      </Relationships>
     </Item>
    </AML>

    It looks like the contents of the <Class_structure> tag are wrapped in a CDATA wrapper. your code should look like 

    <class_structure><![CDATA[ your class structure here ]]</class_structure>

    I'm curious why you're using AML for something like this? Generally going into the instance for a change like this would make more sense, where you can then export it and reimport if necessary.

    AJ

Children