CA Service Management

 View Only
  • 1.  How to determine the environment and pass to a plugin

    Posted Apr 07, 2017 10:40 AM

    I have a form in Service Catalog that accesses an external database using a plugin and I need to pass the environment (test, QA, production) to the database query.  I can determine the environment by using a ReportQuery to get the Service Catalog server name, but I am having trouble getting that derived value passed to the plugin.

     

    What I have tried: 

    I use a java script function that 1) parses the server name from the ReportQuery to get the environment and 2) sets a text field in the form to that environment.  I call that function in the onLoad attribute of the form.  I can see the value in the text field when the form gets loaded, but the environment getting passed into the plugin is not that value.  The value that gets passed is 'TEST', which is the default value on the text field.

     

    How can I get the derived environment value to pass to the plugin?

     

    Here are the two pertinent form components:
     Text field       

    • id:   server_env  
    • name:  server_env  
    • value:  TEST

    Select

    • id:  sel_aix  
    • Report/Plug-in Id:   QueryDatabasePlugin
    • Report/Plug-in Variables: $({'serverEnv':ca_fdGetTextFieldValue(ca_fd.formId, 'server_env')})

     

    Thanks!



  • 2.  Re: How to determine the environment and pass to a plugin

    Broadcom Employee
    Posted Apr 26, 2017 06:00 AM

    Hi Michele,

     

    Not sure if you already followed this document for creating the plugins but I hope this documentation could help you achieve your requirement

     

    https://docops.ca.com/ca-service-management/14-1/en/building/building-ca-service-catalog/use-api-plug-ins-to-load-data-into-policies-and-forms

     

    Hope this helps



  • 3.  Re: How to determine the environment and pass to a plugin

    Posted Apr 26, 2017 01:40 PM

    Thanks for your input!  My issue was getting the dynamic environment to correctly pass into the plug-in.  Since I could not figure this out, I added logic to the plugin to determine the environment.



  • 4.  Re: How to determine the environment and pass to a plugin
    Best Answer

    Posted Apr 26, 2017 02:16 PM

    ca_reportQuery is an asynchronous function.

     

    Your problem seems to be that your plugin gets the textfield value before the ca_reportQuery completes

     

    Hope this helps.



  • 5.  Re: How to determine the environment and pass to a plugin

    Posted Apr 26, 2017 03:48 PM

    Yes, I think you're right.

     

    Thanks!