Can not retrieve Relations using API

Options

Hello,

I have a relation in my Content Type Definition. And I am trying to retrieve that relation using the following code

AttributedObject[] relatedProducts = ci.getRelations( "RELATION-ID" );

But I am getting the null value.

I also checked whether there are any relations available with

Arrays.toString(ci.getAttributeNames());

But that also returns an empty array.

Do I need to make any change in my CTD, so that the relation starts to appear to the API?

Comments

  • Qutubuddin
    Options

    Relation name is different from Field name, you seem to be using a field name and not Relation XML name.

    AttributedObject[] relatedProducts = ci.getRelations( <relantion-xml-name> );

    I hope this helps.