Tuesday, August 16, 2011

WPS: Custom Call For RelationShip

ServiceManager serviceMngr = new ServiceManager();
RelationshipService relationshipService = (RelationshipService)serviceMngr.locateService("com/ibm/wbiserver/rel/RelationshipService");
int instanceIDS[] = relationshipService.retrieveInstanceIDs("<Relationship namespace>/<Relationship name>", "<Source Role namespace>/<Source Role>", <Source BO Name>);   
if(instanceIDS != null && instanceIDS.length > 0) {
    List<DataObject> participants  = relationshipService.retrieveParticipants("<Relationship namespace>/<Relationship name>", "<Target Role namespace>/<Target Role>" ,instanceIDS[0]);
    DataObject prtcpnt = participants.get(0);
    String TargetVariable  = prtcpnt.getString("<target Required String>");
}