This is how you can do it:
/**
@returns {boolean} boolean true/false
*/
function isInTransactionF() {
var isInTransaction = true ; // Boolean
if(isInTransaction) {
// if( Boolean(isInTransaction)) { // alternative
return true;
} else{
return false;
}
}
You can call console.log to see the returned result
console.log("The return result is " + isInTransactionF() );` // true
You can also restrict a participant to create an asset ONLY through a certain transaction class, something like this:
rule CreateAssetThruTxn {
description: "sample""
participant(p): "com.example.User"
operation: CREATE
resource(r): "com.example.UserAsset"
transaction(tx): "com.example.AssetCreate"
condition:(true)
action: ALLOW
}