Upload missing document relationship in Process Plan. "Add" statement doesn't work

オフライン

I need to upload relationship between Operation Document and the Documents. 
As you can see from the picture below the hierarchy of Process Plan is: 

Process Plan--> Operation Number (which is `sort_order`, in this case it is 20)-->Document

I have an excel sheet of the missing documents that need to show under an operation (20)

The document relationship cannot by uploaded just to Operation because the operation 20 will exist under other Process Plans. 

However, under one process plan the operation number is unique, so in this case there will be only one operation with sort_order 20. 

The documents already exist, I just need them to be shown here.

From the AML script I have the `get` command works. The code is below. 

<AML>
<Item type="mpp_processPlan" action="get">
<item_number>080824-S10</item_number>
<Relationships>
   <Item type="mpp_Operation" action="get">
  <sort_order>20</sort_order>
  <Relationships>
     <Item type="mpp_operationDocument" action="get">
  </Item>
</Relationships>
</Item>
    </Relationships>
</Item>
</AML>

However, in the above script in the line `<Item type="mpp_operationDocument" action="get">` when `action = Update` it won't work. 
Basically the following doesn't work

<AML>
<Item type="mpp_processPlan" action="get">
<item_number>080824-S10</item_number>
<Relationships>
<Item type="mpp_Operation" action="get">
<sort_order>20</sort_order>
<Relationships>
<Item type="mpp_operationDocument" action="Update">

<item_number>MADL074161</item_number>
</Item>
</Relationships>
</Item>
</Relationships>
</Item>
</AML>



Result of scriopt with all `action=get`

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<Result>
<Item type="mpp_ProcessPlan" typeId="4E030A4723224002B3E94F40F01AC1DE" id="767F3FCDCC0F4CCF95F3CA3D9DB9D391">
<config_id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</config_id>
<created_by_id keyed_name="Data Migration" type="User">08880028FF8C43D48CB02B44EB74B127</created_by_id>
<created_on>2024-02-20T11:49:02</created_on>
<current_state name="Released" keyed_name="Released" type="Life Cycle State">7109CDD337C84AFF87F55B21CCAC34AC</current_state>
<description></description>
<generation>1</generation>
<has_change_pending>0</has_change_pending>
<id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</id>
<is_current>1</is_current>
<is_released>1</is_released>
<keyed_name>080824-S10</keyed_name>
<location>10</location>
<major_rev>PP000</major_rev>
<modified_on>2024-02-20T11:49:02</modified_on>
<name>Slitter Knife Arm, Rotary Tip, 35" Ring, C/R</name>
<new_version>1</new_version>
<not_lockable>0</not_lockable>
<owned_by_id keyed_name="Mfg Eng" type="Identity">D46B8ECBDB0C4D94BFF7A93D36FAB474</owned_by_id>
<permission_id keyed_name="Process Plan - Released" type="Permission">E4EB045B2622409BA09AC91778FAE18C</permission_id>
<release_date>2024-01-29T00:00:00</release_date>
<state>Released</state>
<item_number>080824-S10</item_number>
<itemtype>4E030A4723224002B3E94F40F01AC1DE</itemtype>
<Relationships>
<Item type="mpp_Operation" typeId="91B674D7C7AF47F99CA1C2FB26C38DBF" id="77DD37200C7B4858833A6D6D8A48F4FA">
<config_id keyed_name="20" type="mpp_Operation">77DD37200C7B4858833A6D6D8A48F4FA</config_id>
<created_by_id keyed_name="Data Migration" type="User">08880028FF8C43D48CB02B44EB74B127</created_by_id>
<created_on>2024-02-20T12:06:27</created_on>
<cycle_time>60</cycle_time>
<description xml:lang="en">MC-1B MC2 CNC Machine Centre S10</description>
<generation>1</generation>
<id keyed_name="20" type="mpp_Operation">77DD37200C7B4858833A6D6D8A48F4FA</id>
<is_current>1</is_current>
<is_released>0</is_released>
<keyed_name>20</keyed_name>
<major_rev>PP000</major_rev>
<modified_on>2024-02-20T12:06:27</modified_on>
<name xml:lang="en">MC-1B</name>
<new_version>1</new_version>
<nmg_erp_name>MC-1B</nmg_erp_name>
<nmg_location_id>10</nmg_location_id>
<not_lockable>0</not_lockable>
<permission_id keyed_name="Process Plan - Released" type="Permission">E4EB045B2622409BA09AC91778FAE18C</permission_id>
<setup_time>0</setup_time>
<source_id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</source_id>
<wi_details xml:lang="en"></wi_details>
<sort_order>20</sort_order>
<Relationships>
<Item type="mpp_OperationDocument" typeId="38BA57E0616B49A58317C267E436AE4C" id="106F5032EE7F4C5497717888370A3BB6">
<config_id keyed_name="106F5032EE7F4C5497717888370A3BB6" type="mpp_OperationDocument">106F5032EE7F4C5497717888370A3BB6</config_id>
<created_by_id keyed_name="Data Migration" type="User">08880028FF8C43D48CB02B44EB74B127</created_by_id>
<created_on>2024-02-20T12:36:02</created_on>
<generation>1</generation>
<id keyed_name="106F5032EE7F4C5497717888370A3BB6" type="mpp_OperationDocument">106F5032EE7F4C5497717888370A3BB6</id>
<is_current>1</is_current>
<is_released>0</is_released>
<keyed_name>106F5032EE7F4C5497717888370A3BB6</keyed_name>
<major_rev>A</major_rev>
<modified_on>2024-02-20T12:36:02</modified_on>
<new_version>1</new_version>
<not_lockable>0</not_lockable>
<permission_id keyed_name="Process Plan - Released" type="Permission">E4EB045B2622409BA09AC91778FAE18C</permission_id>
<related_id keyed_name="MADL074152" type="Document">
<Item type="Document" typeId="B88C14B99EF449828C5D926E39EE8B89" id="BD9ECB6D5C5D4AEEBC0ED65680C5505C">
<classification>Manufacturing Aid</classification>
<config_id keyed_name="MADL074152" type="Document">BD9ECB6D5C5D4AEEBC0ED65680C5505C</config_id>
<created_by_id keyed_name="NMIS _MADL" type="User">41E9090B65234C899CAFF690C7C0F562</created_by_id>
<created_on>2024-02-19T11:12:07</created_on>
<current_state name="Released" keyed_name="Released" type="Life Cycle State">8EDE39438A7E4A56A1B4A9D07EF4A2FF</current_state>
<description>35" SLITTER ARM C/R</description>
<effective_date>2018-11-16T14:35:00</effective_date>
<generation>1</generation>
<has_change_pending>0</has_change_pending>
<has_files>1</has_files>
<id keyed_name="MADL074152" type="Document">BD9ECB6D5C5D4AEEBC0ED65680C5505C</id>
<is_current>1</is_current>
<is_released>1</is_released>
<is_template>0</is_template>
<keyed_name>MADL074152</keyed_name>
<major_rev>V007</major_rev>
<modified_on>2007-07-09T08:17:00</modified_on>
<name>080824</name>
<new_version>0</new_version>
<nmg_department>Manufacturing</nmg_department>
<nmg_type>Program (CAD/CAM)</nmg_type>
<not_lockable>0</not_lockable>
<owned_by_id keyed_name="Mfg Eng" type="Identity">D46B8ECBDB0C4D94BFF7A93D36FAB474</owned_by_id>
<permission_id keyed_name="Released Document" type="Permission">74C205C37E7C4D56BBBE99B52B28431E</permission_id>
<release_date>2018-11-16T14:35:00</release_date>
<state>Released</state>
<item_number>MADL074152</item_number>
<itemtype>B88C14B99EF449828C5D926E39EE8B89</itemtype>
</Item>
</related_id>
<source_id keyed_name="20" type="mpp_Operation">77DD37200C7B4858833A6D6D8A48F4FA</source_id>
</Item>
</Relationships>
</Item>
</Relationships>
</Item>
</Result>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Parents
  • Hi,

    don´t write "Update" in uppercase letters. Either use update or edit.

    In addition this line will not work:

    <Item type="mpp_operationDocument" action="Update">
    <item_number>MADL074161</item_number>
    </Item>

    mpp_operationDocument uses the related_id property to link the document. If you want to work with the item_number, you will need an additional level in your AML to get the "Document" item according to it´s number.

    Something like this:

    <Item type="mpp_operationDocument" action="edit">
      <related_id>
        <Item action="get" type="Document">
            <item_number>MADL074161</item_number>
        </Item>
      </related_id>
    </Item>

  • 0 オフライン in reply to AngelaIp

    Thanks for replying but it doesn't work, I get sliglty different output though. Previously, the output would contain the existing document. 
    Adding your snippet doesn't return mpp_operationDocument. It could be because we are editing and not "getting".
    I tried your snippet with "edit" and "update", the result is the same, no mpp_operationDocument.

    Do I need to declare <source_id>? I tried that too. I added this line 

    <Item type="mpp_processPlan" action="get">

    <source_id>
    <item_number>080824-S10</item_number>

    </source_id>

    This returns mixed up data for different process plans and operations, and not specificially for 080824-S10.

    My complete code with your snippet and output is: 
    code: 

    <AML>
    <Item type="mpp_processPlan" action="get">
    <item_number>080824-S10</item_number>
    <Relationships>
    <Item type="mpp_Operation" action="get">
    <sort_order>20</sort_order>
    <Relationships>
    <Item type="mpp_operationDocument" action="update">
    <related_id>
    <Item type="Document" action="get">
    <item_number>MADL074161</item_number>
    </Item>
    </related_id>
    </Item>
    </Relationships>
    </Item>
    </Relationships>
    </Item>
    </AML>


    Output: As you can see there is no mpp_operationDocument in this

     

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
    <Result>
    <Item type="mpp_ProcessPlan" typeId="4E030A4723224002B3E94F40F01AC1DE" id="767F3FCDCC0F4CCF95F3CA3D9DB9D391">
    <config_id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</config_id>
    <created_by_id keyed_name="Data Migration" type="User">08880028FF8C43D48CB02B44EB74B127</created_by_id>
    <created_on>2024-02-20T11:49:02</created_on>
    <current_state name="Released" keyed_name="Released" type="Life Cycle State">7109CDD337C84AFF87F55B21CCAC34AC</current_state>
    <description></description>
    <generation>1</generation>
    <has_change_pending>0</has_change_pending>
    <id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</id>
    <is_current>1</is_current>
    <is_released>1</is_released>
    <keyed_name>080824-S10</keyed_name>
    <location>10</location>
    <major_rev>PP000</major_rev>
    <modified_on>2024-02-20T11:49:02</modified_on>
    <name>Slitter Knife Arm, Rotary Tip, 35" Ring, C/R</name>
    <new_version>1</new_version>
    <not_lockable>0</not_lockable>
    <owned_by_id keyed_name="Mfg Eng" type="Identity">D46B8ECBDB0C4D94BFF7A93D36FAB474</owned_by_id>
    <permission_id keyed_name="Process Plan - Released" type="Permission">E4EB045B2622409BA09AC91778FAE18C</permission_id>
    <release_date>2024-01-29T00:00:00</release_date>
    <state>Released</state>
    <item_number>080824-S10</item_number>
    <itemtype>4E030A4723224002B3E94F40F01AC1DE</itemtype>
    <Relationships>
    <Item type="mpp_Operation" typeId="91B674D7C7AF47F99CA1C2FB26C38DBF" id="77DD37200C7B4858833A6D6D8A48F4FA">
    <config_id keyed_name="20" type="mpp_Operation">77DD37200C7B4858833A6D6D8A48F4FA</config_id>
    <created_by_id keyed_name="Data Migration" type="User">08880028FF8C43D48CB02B44EB74B127</created_by_id>
    <created_on>2024-02-20T12:06:27</created_on>
    <cycle_time>60</cycle_time>
    <description xml:lang="en">MC-1B MC2 CNC Machine Centre S10</description>
    <generation>1</generation>
    <id keyed_name="20" type="mpp_Operation">77DD37200C7B4858833A6D6D8A48F4FA</id>
    <is_current>1</is_current>
    <is_released>0</is_released>
    <keyed_name>20</keyed_name>
    <major_rev>PP000</major_rev>
    <modified_on>2024-02-20T12:06:27</modified_on>
    <name xml:lang="en">MC-1B</name>
    <new_version>1</new_version>
    <nmg_erp_name>MC-1B</nmg_erp_name>
    <nmg_location_id>10</nmg_location_id>
    <not_lockable>0</not_lockable>
    <permission_id keyed_name="Process Plan - Released" type="Permission">E4EB045B2622409BA09AC91778FAE18C</permission_id>
    <setup_time>0</setup_time>
    <source_id keyed_name="080824-S10" type="mpp_ProcessPlan">767F3FCDCC0F4CCF95F3CA3D9DB9D391</source_id>
    <wi_details xml:lang="en"></wi_details>
    <sort_order>20</sort_order>
    </Item>
    </Relationships>
    </Item>
    </Result>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

  • Ah I see. There are two options.

    The most reliable way is to edit the complete chain (edit ProcessPlan, edit Operation, edit DocRelationship with a Document you get). For editing an item, you also need to use "where" to specify which element you want to edit.

    <AML>
    <Item type="mpp_processPlan" action="edit" where="[mpp_processPlan].item_number='123'">
    <Relationships>
    <Item type="mpp_Operation" action="edit">
    <sort_order>20</sort_order>
    <Relationships>
    <Item type="mpp_operationDocument" action="edit">
    <related_id>
    <Item type="Document" action="get">
    <item_number>MADL074161</item_number>
    </Item>
    </related_id>
    </Item>
    </Relationships>
    </Item>
    </Relationships>
    </Item>
    </AML>

    Or you just edit the relationship itself with source_id and related_id. An AML query without the parent levels of the chain would work, but have to know the source_id or get it based on the Operation (which is probably not a unique item). I personally would use the first option.

Reply
  • Ah I see. There are two options.

    The most reliable way is to edit the complete chain (edit ProcessPlan, edit Operation, edit DocRelationship with a Document you get). For editing an item, you also need to use "where" to specify which element you want to edit.

    <AML>
    <Item type="mpp_processPlan" action="edit" where="[mpp_processPlan].item_number='123'">
    <Relationships>
    <Item type="mpp_Operation" action="edit">
    <sort_order>20</sort_order>
    <Relationships>
    <Item type="mpp_operationDocument" action="edit">
    <related_id>
    <Item type="Document" action="get">
    <item_number>MADL074161</item_number>
    </Item>
    </related_id>
    </Item>
    </Relationships>
    </Item>
    </Relationships>
    </Item>
    </AML>

    Or you just edit the relationship itself with source_id and related_id. An AML query without the parent levels of the chain would work, but have to know the source_id or get it based on the Operation (which is probably not a unique item). I personally would use the first option.

Children
  • 0 オフライン in reply to AngelaIp

    Awesome! I made it work with some tweaks. Apparently I need to use "id" for mpp_operation only, regardles of "update", "edit" or "add" action for mpp_operation, otherwise I get this error

    <faultstring><![CDATA[Mandatory attribute "id" is missed at mpp_Operation item node]]></faultstring>

    Any way to make this work without using id. I have a csv file to upload and it doesn't contain the IDs. The idea was to try out AML and if it works copy paste it in the batch-loader. 

    Script:

    <AML>
    <Item type="mpp_processPlan" action="edit" where="[mpp_processPlan].item_number='D52229-S10'">
    <Relationships>
    <Item type="mpp_Operation" action="">
    <sort_order>30</sort_order>
    <Relationships>
    <Item type="mpp_operationDocument" action="add">
    <related_id>
    <Item type="Document" action="get">
    <item_number>MADL109444</item_number>
    </Item>
    </related_id>
    </Item>
    </Relationships>
    </Item>
    </Relationships>
    </Item>
    </AML>