Normally the paths associated with Valence apps are hard-coded to specific values that never change. The users clicks on the app and the Valence Portal directs them to a specific IFS path or web page. But what if you had a special use case where you wanted to alter the IFS path or URL based on who is logged in, or depending on which environment they're using? This can be done using a special exit program technique that will dynamically alter the path of an app upon being launched from the Valence Portal. To illustrate the concept, let's say you have an app configured to show a web page that sends users to an external site listing all of the ACME Company products -- hypothetically we'll say the URL is http://www.acme.com/products -- and the page optionally accepts query parameters to filter what shows, such that http://www.acme.com/products?buyerID=12345 would limit the list to those relevant to buyer ID 12345. Of course, you couldn't hard-code this buyer ID into the URL of the app because the value would likely be different for each user. But you could dynamically construct it using an exit program, thereby saving your users the extra keystrokes or clicks they'd need to do in order to filter the data on the page themselves. An exit program in the path or URL of a Valence App is referenced by enclosing a program name in hard brackets and a pair of pound symbols, i.e. [##PROGRAM##]. So if you created a simple RPG program called, say, GETBUYERID to pull in the buyer ID associated with the current user for our hypothetical example, you could incorporate that into the URL like this: http://www.acme.com?userType=[##GETBUYERID##]. Upon launching an app with this path, the GETBUYER program would be called to return appropriate value to construct the URL. The custom program referenced in an app path in this manner must accept three parameters: The session ID (64A), the app ID (10i0), and the return value to substitute (256A). Take a look at example program EXEXITPGMS for sample code applying this concept, and see the Valence App Setup Guide for further details on using subsitution values in the app path.

CategoryTip of the MonthValence