title: Hyperledger Composer - ACL Rule with function in condition
body: <p>I'm trying to write a little complexer logic in the condition of an ACL Rule as always the <code>p.getIdentifier() == r.getIdentifier()</code>, because in my fault it isn't possible.</p>
  
  <p>These are my models:</p>
  
  <pre><code>participant Customer identified by customerID {
    o String  customerID
    o String  name
    ...
  }
  
  asset A identified by aID {
    o String       aID
    --&gt; Customer   customer
  }
  
  asset B identified by bID {
    o String  bID
    --&gt; A     a
  }
  </code></pre>
  
  <p>Now I want to give the <code>Customer</code> access to see all <code>B</code> assets, but only where the relationship to <code>A</code> references to an asset, which have a relatinship to the actual participant of <code>Customer</code>, who is "logged in".</p>
  
  <p>Summarized logic: From asset <code>B</code> to <code>A</code>, and then from <code>A</code> to <code>Customer</code>.</p>
  
  <p>So in this case I can't compare the identifiers of <code>Customer</code> and <code>B</code> directly and have to go over <code>A</code>. Therefore I wanted to evaulate the access with a function which is called in the <code>script.js</code> file:</p>
  
  <pre><code>rule CustomerAccessCustomer {
    description: "The customer should see all B assets, but only when he have a relationship in asset A "
    participant(p): "org.xxx.test.participant.Customer"
    operation: READ
    resource(r): "org.xxx.test.asset.B"
    condition: (evaluateAccess(p,r))
    action: ALLOW
  }
  </code></pre>
  
  <p>Here is the function of the <code>script.js</code>:</p>
  
  <pre><code>async function evaluateAccess(p,r) {
    try {
      const bRegistry = await getAssetRegistry('org.xxx.test.asset.B');
      const b = await bRegistry.get(r.getIdentifier());
  
      const aRegistry = await getAssetRegistry('org.xxx.test.asset.A');
      const a = await aRegistry.get(b.a.getIdentifier());
  
      if (p.getIdentifier() === a.customer.getIdentifier()) {
          return true;
      }
    } catch (error) {
      console.log(error);
    }
  }
  </code></pre>
  
  <p>But I get an error <code>Error: The runtime API is not available</code>.</p>
  
  <p>Do I think the wrong way, isn't it possible to evaluate access with a function?
  How did you handle access rule if you can't just compare the identifiers?</p>