Apigee vs Javascript Variable in conditions

Not applicable

I am using one variable name cacheEntry to populate it with Apigee cache values, if value doesn't exist I call another service using callout and get response and populate cacheEntry variable using javascript code using repsonse from service callout and then use it again to populate apigee cache. The problem I see is that in condition in my flows, it seems, the conditions are evaluated based on value of cacheEntry variable populated by Apigee cache in first step. So it seems the Javascript based cacheEntry variable can not be used in conditions , is that correct ?

0 3 336
3 REPLIES 3

HI @Mayank

Your use case can be built easily. However, its difficult to describe all that. If you could share your proxy, I can probably look at it and see. You can download the proxy using the UI and attach it here

Not applicable

Hello Mayank,

I just did similar work yesterday and hence sharing with you. In this example, I am first checking the data in the cache. If it does not exist, then I am executing my policy (In your case it would be a java callout). If the result of that policy execution is successful (not null), I am adding the data in the cache.

<Step>
    <Name>RetrieveDataFromCache</Name>
</Step>
<Step>
    <Condition>(Details = null)</Condition>
	<Name>Entity.Developer</Name>
</Step>
<Step>
    <Condition>(AccessEntity.Entity.Developer != null)</Condition>
    <Name>SaveDataInCache</Name>
</Step>

And here are the policy details

<LookupCache enabled="true" continueOnError="false" async="false" name="RetrieveDataFromCache">    
<CacheResource>data-cache</CacheResource>
    <AssignTo>Details</AssignTo>
    <Scope>Global</Scope>
    <CacheKey>
        <KeyFragment ref="developer.email"></KeyFragment>
        <KeyFragment ref="developer.app.name"></KeyFragment>
    </CacheKey>
</LookupCache>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AccessEntity async="false" continueOnError="false" enabled="true" name="Entity.Developer">
    <DisplayName>Entity.Developer</DisplayName>
    <FaultRules/>
    <Properties/>
    <EntityIdentifier ref="client_id" type="consumerkey"></EntityIdentifier>
    <EntityType value="developer"></EntityType>
</AccessEntity>
<PopulateCache enabled="true" continueOnError="false" async="false" name="SaveDataInCache">
    <CacheResource>data-cache</CacheResource>
    <Source>AccessEntity.Entity.Developer</Source>
    <Scope>Global</Scope>
    <CacheKey>
        <KeyFragment ref="developer.email"></KeyFragment>
        <KeyFragment ref="developer.app.name"></KeyFragment>
    </CacheKey>
    <ExpirySettings>
        <TimeoutInSec ref="CacheStorageTime"></TimeoutInSec>
    </ExpirySettings>
</PopulateCache>

Hope this helps

@Meghdeep, Thanks but I already have the flow working, cache look up and populate is not the problem here but the problem is " variables are being set properly in various policy but conditions are not getting executed based on intermediate values of variable it seems conditions in proxyendpoint in flow are only working based on first set value of variable and not the intermediate ". We want to skip certain policies in our flow if there is based on different values of cacheEntry during intermediate processing but that's not happening as expected. Let me do more research on this.