I found the exact solution and syntax.. This is for the marbles trading demo and it checks for presence of both participant and the asset
/**
* Trade a marble to a new player
* @param {org.hyperledger_composer.marbles.TradeMarble} tradeMarble - the trade marble transaction
* @transaction
*/
function tradeMarble(tradeMarble) {
return getParticipantRegistry('org.hyperledger_composer.marbles.Player')
.then(function(playerRegistry) {
return playerRegistry.exists(tradeMarble.newOwner.getIdentifier())
})
.then(function(exists) {
if(!exists) {
throw Error('Invalid participant id')
} else {
return getAssetRegistry('org.hyperledger_composer.marbles.Marble')
.then(function (assetRegistry) {
tradeMarble.marble.owner = tradeMarble.newOwner;
return assetRegistry.update(tradeMarble.marble);
});
}
})
}