How to check previous policy execute successfully or not?

Hi,

I have 2 policy in one flow, always 2nd policy has to execute only if 1st policy got some exception or fault.if 1st policy execute successfully 2nd policy should not execute.

Solved Solved
0 9 860
1 ACCEPTED SOLUTION

Have your second policy under <FaultRule> section of your flow. It will get executed only if there is an exception in the first policy. This has already been discussed here.

View solution in original post

9 REPLIES 9

Have your second policy under <FaultRule> section of your flow. It will get executed only if there is an exception in the first policy. This has already been discussed here.

Thanks Sudheendra for Ur reply.but if i configured 2nd policy in fault-rule, after executing 2nd policy response will go to client it won't go for target-end point.In my case i need hit target end point.

what is your first policy? [like Oauth or quota etc?], you could configure your first policy to continue on error and depending on the policy we might be able to find it has failed or not

Not applicable

Veerendra Deshpande, If you want this to do on scripts , you can set a flag + continue on error as @mukundha@apigee.com mentioned and execute the second policy based on a condition on the flag .

If you want to this on non-script policies , you can check for any variable that will be set in 1st policy as condition on second policy .

For example , in case of Oauth as shown below you can check for oauthV2.failed or any variables that you think will be set and in case of quota you can get the actual count at any point of time .

<Step>
<Condition>(oauthV2.failed = null or oauthV2.failed = "true") </Condition>
<!--  Get Key from Map -->
<Name>GetKey</Name>
</Step>

It really depends on what policy you want to achieve this .

Hi Maruthi Chand,Thanks for ur reply it works fine for oauthV2,To check previous policy failed or not, condition is changing from policy to policy like

For OAuthV2 "oauthV2.failed = "true""

For Service Callout "servicecallout.<<policy_name>>.failed= true"

Why condition getting changing policy to policy? if i want check same thing for another policy how to find out what should LHS in the condition?

Hi @Veerendra Deshpande , Unfortunately those kind of variables are unavailable for all policies as of now but the question is can't we not handle your scenario using the existing functionalities ?

Can you provide more information on your case so that some one here or I can help you . Thanks .

akoo
Participant V

In Public Cloud 15.04+, there is the variable you can inspect in Analytics: apigee.edge.execution.fault_policy_name. The value will be null if no policy failed, otherwise it will have the value of the policy that failed.

@Alex Koo I see apigee.edge.execution.fault_policy_name, apigee.edge.execution.fault_flow_name, and apigee.edge.execution.fault_flow_state in custom reports, but can't seem to access them in a proxy, for example by using ExtractVariables. Are they not available in a flow?

Thanks,

Stephen

@sgilson You're right. I'll include that in my answer.