Layer7 API Management

  • 1.  Extract value from parent resource output in child resource Javascript LAC?

    Posted May 29, 2018 06:30 AM

    In LAC, I created a new resource(say XYZ) which is Table-Based Resource and then created a new level(say ABC) under that resource which is JavaScript Resource. So in my javascript, I want to extract one-row value i.e. Date from XYZ and then compare with the sys date and then return the TRUE or FALSE response.

     

    So how can I extract the field value from parent resource(XYZ) and populate in my child resource(ABC) which is JAVASCRIPT based?

     

    Ex:

    Resource XYZ(Parent): Table Based

    Returns: {"date":"28/05/2018","time":"8pm","place":"Mumbai"}

     

    Resouce ABC(Child): Javascript Based

    I want to get the value of date from parent resource and compare it with my system data.

     

    I am not able to extract the value. SO is it even possible or not? If yes, then how?

     

    Thanks!!



  • 2.  Re: Extract value from parent resource output in child resource Javascript LAC?

    Broadcom Employee
    Posted Jun 21, 2018 01:47 PM

    In your JavaScript resource (which is a child resource, if I understood you correctly), whenever your JavaScript code gets called, there should see a variable called "containingRow", which I am now noticing is not exposed in the code editor using autocomplete, so thanks for pointing that out -- we'll fix it. It is documented, though:

     

    https://docops.ca.com/ca-live-api-creator/4-1/en/creating-apis/customize-your-api/define-javascript-resource-types#DefineJavaScriptResourceTypes-ExampleJavaScriptResource 

     

    Please let us know if that doesn't answer your question, and thanks for your input!



  • 3.  Re: Extract value from parent resource output in child resource Javascript LAC?

    Broadcom Employee
    Posted Dec 17, 2018 11:43 AM

    Good afternoon,

     

    Were you able to resolve the issue? What was the final result?

     

    Sincerely,


    Stephen Hughes
    Broadcom Support