How to get the associated object of an entity in custom widget?

Hi all, I am passing an entity for example A to my custom widget and sending the context entity B too. They both have association one B object can have multiple A objects mapped. Now I need to get the data from A which are associated to B only. I cannot pass it through constraint. So from context entity  B I am getting Name attribute. I would like to get the data from A by getting associated object of B and compare with How can I achieve this? I got stuck at retrieving the association of B from A object. Thanks in advance.
1 answers

Hi Sushuma,

I hope I understand your question correctly; is it a many-to-many association? It sounds like you only need the name of the object B and feed that as a variable in the following JavaScript client API call to get the associated objects of type A. So, say you have a module named 'ModuleName' and a variable <NameOfB> which holds the name of the target instance of object type B, the following JS code should retrieve the associated objects of type A:{
    xpath: "//ModuleName.A/ModuleName.A_B/ModuleName.B[Name = " + <NameOfB> + "]",
    callback: function(objs) {
        console.log("Received " + objs.length + " MxObjects of type A associated to object B with name: " + <NameOfB>);