Topic
  • 1 reply
  • Latest Post - ‏2019-08-15T16:06:58Z by swlinn
benji-bin
benji-bin
2 Posts

Pinned topic Issue with dynamic configuration parameter using GatewayScript

‏2019-08-13T15:35:30Z |

Hi all,

i have an issue while configuring dynamic configuration parameter using GatewayScript. i followed same instruction in the manual (https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.6.0/com.ibm.dp.doc/var-service-config-param_reference.html) but can't create the configuration parameter. 

var servicevars = require('service-metadata');

servicevars.setVar('var://service/config-param/ID', 'abc-123-0001');

So, later in my script, when i try to access the parameter (ID) using session.parameter.ID, I got 'undefinedfor that parameter value.

Also, i can use this service variable configuration to create/update service level configuration parameter, right? if it works with an update, for next service invocation, the dynamic configuration parameter will hold the updated value? Is there anything i missed when configuring?

 

am using IDG firmware 2018.4.1.5 (Docker)

 

Thanks

Updated on 2019-08-13T15:59:54Z at 2019-08-13T15:59:54Z by benji-bin
  • swlinn
    swlinn
    1445 Posts

    Re: Issue with dynamic configuration parameter using GatewayScript

    ‏2019-08-15T16:06:58Z  

    The session object is setup when the gatewayscript is invoked.  A subsequent gatewayscript would have the ID parameter present. 

    I did a simple test with your code where I had two gatewayscripts.  The first set the config-parameter as you did, and as you saw it was not in the session object in that first gatewayscript.  However, in the subsequent gatewayscript, it is there, as shown in my debugger print 

    (debug) p session.parameters
    { ID: 'abc-123-0001' }

    If you are wanting the session object in the same script to be updated by setting this system variable, that will not work. If you need this value to be available in the session.parameters for a subsequent portion of this script (and only this script), you can update the session.parameters to add or update parameters.  Simply do the following:

    session.parameters.ID = 'abc-123-0001';

    Then other places in this script can use session.parameters.ID to get the value.  Also note that you can pass a parameter into the gatewayscript by using the add parameter button on the advanced tab of the gatewayscript action.  The use of the system variable is meant to be used for dynamically setting these parameters, perhaps based on some data seen in a request.

    Regards,
    Steve