Add Multiple Child Records Without Passing PRODUCTID and PRODUCTID EXT in REST

Add Multiple Child Records Without Passing PRODUCTID and PRODUCTID EXT in REST

book

Article ID: KB0079464

calendar_today

Updated On:

Products Versions
TIBCO MDM 9.1

Description

We need to send a REST request to add more than one child record without passing PRODUCT ID and ID EXTENSION as an input.It should generate RECORD ID and EXTN based on the sequence along with relationship records.

Below is the repository hierarchy to add more than one child record without Passing PRODUCTID and ID EXT in input as below.

A1 >> B1
     >> B2

Issue/Introduction

Need to add more than one child record along with parent without passing PRODUCT ID and ID EXTENSION by using REST

Environment

ALL

Resolution

MDM can only make relationships between records with keys, and in this case MDM is adding "Dummy" to the parent and/or child AFTER it has attempted to match them up.

So,we need to pass "Dummy" as the ProductId,ID Extension and have in the rulebase that processes the records something that changes dummy to an actual key value .By adding in Dummy at the start, then MDM "Knows" which records to sow together.

Below is the sample SOAP UI request which will pass ID and ID Extension values DUMMY as an Input.

{
  "process":true,
  "validate":true,
  "record":{

    "attributes":[
        {  
                        "name":"productId",
                        "value":"DUMMY1"

                     },
         {  
                        "name":"UOM",
                        "value":"33636"

                     },
                     {  
                        "name":"DESCRIPTION",
                        "value":"own"

                     }
    ],
    "repositoryName":"A",
    "relationships":{
      "AtoB":[
        {
        "relationshipAttributes": [],
          "targetRecord":{

                   "productId":" ",
                  "productIdExt":"DUMMY2",
                  "attributes":[  
                     {  
                        "name":"PRODUCTID",
                        "value":" ",
                        "displayName":"Record ID",
                        "multivalues":null,
                        "multivalue":false
                     },
                     {  
                        "name":"PRODUCTIDEXT",
                        "value":"DUMMY2",
                        "displayName":"Record ID Extension",
                        "multivalues":null,
                        "multivalue":false
                     },
                     {  
                        "name":"UOM",
                        "value":"123",
                        "displayName":"UOM",
                        "multivalues":null,
                        "multivalue":false
                     }
            ],
            "repositoryName":"B",
            "deleted":false
          }
        },
        {
        "relationshipAttributes": [],
          "targetRecord":{

                 "productId":" ",
                  "productIdExt":"DUMMY3",
                  "attributes":[  
                     {  
                        "name":"PRODUCTID",
                        "value":" ",
                        "displayName":"Record ID",
                        "multivalues":null,
                        "multivalue":false
                     },
                     {  
                        "name":"PRODUCTIDEXT",
                        "value":"DUMMY3",
                        "displayName":"Record ID Extension",
                        "multivalues":null,
                        "multivalue":false
                     }
                     
            ],
            "repositoryName":"B",
            "deleted":false
          }
        }
      ]
    },
    "deleted":false
  }
}


Add below Rulebase constraints should be placed in A repository catalogvalidation.xml file to generate ID for A Record and propagate the same ID to child i.e B.

<constraint>
    <name>SetPID</name>
    <description>Set ProductID if starts with "DUMMY"</description>
    <usefor/>
    <condition>
        <eq>
            <op func="substring">
                <var>PRODUCTID</var>
                <const type="number">0</const>
                <const type="number">5</const>
            </op>
            <const type="string">DUMMY</const>
        </eq>
    </condition>
    <action>
        <assign>
            <var>PRODUCTID</var>
            <op func="sequence">
                <const type="string">MQ_SEQUENCE_1</const>
            </op>
        </assign>
    </action>
</constraint>

<constraint>
        <name>Propagate_A_ProductID_To_B</name>
        <description>Constraint to propagate Product ID to B Repo</description>
        <usefor/>
        <condition>
            <and>
                <defined>
                    <var>PRODUCTID</var>
                </defined>
                <var>RECORD_IS_ROOT</var>
            </and>
        </condition>
        <action>
            <propagate type="inline">
                <var>link_Address</var>
                <action>
                    <assign>
                        <var>PRODUCTID</var>
                        <var>link/PRODUCTID</var>
                    </assign>
                </action>
            </propagate>
        </action>
    </constraint>

Also,We need to add below constraint in the B repository catalogvalidation.xml file to generate ID Extension of B Records.

<constraint>
    <name>SetPID</name>
    <description>Set ProductIDExtn if starts with "DUMMY"</description>
    <usefor/>
    <condition>
        <eq>
            <op func="substring">
                <var>PRODUCTIDEXT</var>
                <const type="number">0</const>
                <const type="number">5</const>
            </op>
            <const type="string">DUMMY</const>
        </eq>
    </condition>
    <action>
        <assign>
            <var>PRODUCTIDEXT</var>
            <op func="sequence">
                <const type="string">MQ_SEQUENCE_2</const>
            </op>
        </assign>
    </action>
</constraint>

By using above rulebase constraints and request,We can add multiple child records without passing any ID's

Additional Information

01649693,Restservcies.pdf

Attachments

Add Multiple Child Records Without Passing PRODUCTID and PRODUCTID EXT in REST get_app
Add Multiple Child Records Without Passing PRODUCTID and PRODUCTID EXT in REST get_app