Visual Builder

Get Involved. Join the Conversation.

Topic

    Nathan Zentner
    Variable Access from Trigger
    Topic posted January 9, 2019 by Nathan ZentnerRed Ribbon: 250+ Points, tagged Business Objects, Groovy 
    103 Views, 8 Comments
    Title:
    Variable Access from Trigger
    Summary:
    Variable Access from Trigger
    Content:

    How can I use application variables within a trigger of a Business Object.

    I could not figure out how to pass or use an Application variable within a groovy trigger.

    $application.variables.<myvarname>

    Comment

     

    • Shay Shmeltzer

      You shouldn't be doing this - since the BO could be used/accessed from other apps/interfaces you shouldn't have direct access to a specific value in a specific UI.

      What's your use case?

      You could use an object level method on the BO and pass parameters to it from the UI when you call it from a specific UI

      For example - Executing a Custom Action Specified by the URL                               

      • Nathan Zentner

        i see your point.

        I am wanting to call a remote rest api server-to-server and not having it originate from the client.  I want to pass variables set within the application like remoteAPIUser and remoteAPIPass that should never be available to the user through research of the network call info.

        Are actions originated on the client or are calls to REST APIs from within action made from the client?

         

      • Nathan Zentner

        I'm assuming you are referring to an Business Object => Business Rule => Object Function?

         

        From within creating parameters and assigning them to application level variables?

    • Shay Shmeltzer

      Assuming that your service require security settings then unless you choose the "Direct (bypass authentication proxy)" option in the call is actually done from the VB server's security proxy and not the client.

      Note that you could call the services you defined in the applications also from the BO triggers.

       

      • Nathan Zentner

        We've come full circle.  If I use a BO trigger, I need to pass an application variable to the service from the BO trigger.

    • Nathan Zentner

      Now that I have worked with it more, I see that what I assumed was wrong.

      Application Variables are written to the client.  So Storing a back-end REST API credentials should not be saved there.  (As far as I can see, there is not place to store server side variables that are not exposed to the client)

      So far I only see that functionality within Groovy is not exposed to the client.  Everything else would be exposed to the client.  I can create a Groovy method that calls the AuthToken for my application and hardcode the credentials, but I think I might have an issue with using the token created to access all the other REST APIs.  The AuthToken returned is encrypted and i believe it has a "caller" variable to it.  So the token is then only useful from the machine it was created on.  All my calls to back REST APIs would have to go through middle tier.

      • Shay Shmeltzer

        Are you defining your service connections through the VB services section? Can't you define the security through the layer it provides rather than code it in your code?

        • Nathan Zentner

          Yes, I'm creating it with the VB Services and I would use the security already provided if it worked with the functionality.  The problem is that the REST APIs can be accessed anonymously, but require a generic user.  You can not access the REST APIs without the API  AuthToken.  When we integrate with other applications, we hardcode these credentials in the calling app.

          1. Create API AuthToken
          2. Create User Token with API AuthToken.

          https://docs.oracle.com/en/cloud/saas/service/18a/cxska/OKCS_Authenticate.html

          Search for "Authenticating and Authorizing the API User"