Add relationship via Agile PLM SDK
com.agile.api.APIException: Invalid parameter.
at com.agile.api.pc.Session.createError(Session.java:2039)
at com.agile.api.pc.APIObject.createError(APIObject.java:76)
at com.agile.api.pc.TableRelationships.convertCreateParamMapToVOCells(TableRelationships.java:92)
at com.agile.api.pc.TablePC.doCreateServerRowWithParam(TablePC.java:58)
at com.agile.api.pc.Table.createTableRow(Table.java:267)
at com.agile.api.pc.Table.createRow(Table.java:231)
The Agile API requires a hashmap with attributes and values as parameter to create the relationship. So this is my code:
val cells: java.utils.Map[_, _] = Map(
Attrs.Items.Relationships.CriteriaMet -> null,
Attrs.Items.Relationships.TypeImage -> 666, // id of item type as Integer
Attrs.Items.Relationships.Name -> 'foo', // name as String
Attrs.Items.Relationships.Description -> 'bar', // the description as String
Attrs.Items.Relationships.CurrentStatus -> 'Production', // lifecyclephase 'Production' as a String
Attrs.Items.Relationships.Rule -> null,
Attrs.Items.Relationships.Type -> 600 // id of item type as Integer
)
relationshipTable.createRow(cells)
The relationshipTable instance is of type ITable and this kind of Map is working for adding BOM items and attachments, so I think this is not the issue here. I simply queried the cells of existing relationships manually and compared their key with my constants used in this map and they are the same. I really don’t know what the invalid parameter is. Is there an attribute missing? Is the type of an parameter wrong? There is no indication what’s wrong.
Ok, the answer was quite simple, despite it works different than for the BOM and it is not documented.
The solution is simply passing the iitem you want to add as a relationship: relationshipTable.createRow(iitem)