How to pass value like appname.varvalue.clientid to KVM?

Hi,

I have used an extract variable policy to extract json field value from incoming json message and assigned it to a variable shipTo. Next I need to pass some value to KVM to get required output against the KVM entry. Format of passing the Get parameter to KVM for lookup is appname.shiptovalue.clientid. appname and clientid will be hardcoded for each KVM lookup but shiptovalue will be the value of shipTo field's value extracted from JSON message. After that KVM output needs to be assigned to a new variable.

Please note that KVM is encrypted one.

In KVM entries are appname.1234.clientid = ******* , appname.4343.clientid = ******

How I can concat appname and clientid with shiptovalue to create a new value and pass it to KVM lookup policy? Kindly suggest.

 

Solved Solved
3 4 117
1 ACCEPTED SOLUTION

In the KVM policy, you can have composite keys. The configuration is like this:​

 

<KeyValueMapOperations name='KVM-Get-1'>
  <Scope>environment</Scope>
  <MapName>fixedNameOfMap</MapName>
  <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
  <Get assignTo='variable.to.set'>
    <Key>
      <Parameter>fixedpart</Parameter>
      <Parameter ref='variable-containing-key-component'/>
      <Parameter>another-fixed-part</Parameter>
    </Key>
  </Get>
</KeyValueMapOperations>

 

​In the above there are 3 key components, and the policy "composes" them into a single key. That might seem like what you want - combining the word "appname" with a variable thing, and then the word "clientid". If you had a variable that held the value for shiptovalue, populated via a prior ExtractVariables step, then that might be just what you want. your key configuration in the policy step might look like this:​

 


  ...
  <Get assignTo='variable.to.set'>
    <Key>
      <Parameter>appname</Parameter>
      <Parameter ref='variable-containing-shipto-value'/>
      <Parameter>clientid</Parameter>
    </Key>
  </Get>
...

 

But what is the resulting key? The documentation for the KeyValueMapOperations step type has this to say about composite keys:

When the <Key> element includes multiple <Parameter> elements, the effective key string is the concatenation of the values of each parameter, joined with a double underscore. For example, in the above example, if the apiproxy.name variable has the value abc1, then the effective key will be targeturl__abc1__weight.

Which means, in your case the resulting key would be appname__4343__clientid, and not appname.4343.clientid .

I can see two ways to do what you want:​

  • Modify your KVM key to use double-underscore instead of dot, as the separator. This specifically applies to the moment you load values into the KVM administratively.
  • Keep your KVM key as is, with the dot separator, and Use an AssignMessage to produce the composite key, using a dot as the separator.

An example of the latter is this:

 

<AssignMessage name='AM-KVM-Key'>
  <AssignVariable>
    <Name>composed-key-for-kvm</Name>
    <Template>appname.{variable-holding-shipto-value}.clientid</Template>
  </AssignVariable>
</AssignMessage>

 

And in that case your KVM policy would use a single parameter for the key, like this:​

 


  ...
  <Get assignTo='variable.to.set'>
    <Key>
      <!-- this key has been composed by a prior AssignMessage step -->
      <Parameter ref='composed-key-for-kvm'/>
    </Key>
  </Get>
...

 

View solution in original post

4 REPLIES 4

Can anyone please suggest?

In the KVM policy, you can have composite keys. The configuration is like this:​

 

<KeyValueMapOperations name='KVM-Get-1'>
  <Scope>environment</Scope>
  <MapName>fixedNameOfMap</MapName>
  <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
  <Get assignTo='variable.to.set'>
    <Key>
      <Parameter>fixedpart</Parameter>
      <Parameter ref='variable-containing-key-component'/>
      <Parameter>another-fixed-part</Parameter>
    </Key>
  </Get>
</KeyValueMapOperations>

 

​In the above there are 3 key components, and the policy "composes" them into a single key. That might seem like what you want - combining the word "appname" with a variable thing, and then the word "clientid". If you had a variable that held the value for shiptovalue, populated via a prior ExtractVariables step, then that might be just what you want. your key configuration in the policy step might look like this:​

 


  ...
  <Get assignTo='variable.to.set'>
    <Key>
      <Parameter>appname</Parameter>
      <Parameter ref='variable-containing-shipto-value'/>
      <Parameter>clientid</Parameter>
    </Key>
  </Get>
...

 

But what is the resulting key? The documentation for the KeyValueMapOperations step type has this to say about composite keys:

When the <Key> element includes multiple <Parameter> elements, the effective key string is the concatenation of the values of each parameter, joined with a double underscore. For example, in the above example, if the apiproxy.name variable has the value abc1, then the effective key will be targeturl__abc1__weight.

Which means, in your case the resulting key would be appname__4343__clientid, and not appname.4343.clientid .

I can see two ways to do what you want:​

  • Modify your KVM key to use double-underscore instead of dot, as the separator. This specifically applies to the moment you load values into the KVM administratively.
  • Keep your KVM key as is, with the dot separator, and Use an AssignMessage to produce the composite key, using a dot as the separator.

An example of the latter is this:

 

<AssignMessage name='AM-KVM-Key'>
  <AssignVariable>
    <Name>composed-key-for-kvm</Name>
    <Template>appname.{variable-holding-shipto-value}.clientid</Template>
  </AssignVariable>
</AssignMessage>

 

And in that case your KVM policy would use a single parameter for the key, like this:​

 


  ...
  <Get assignTo='variable.to.set'>
    <Key>
      <!-- this key has been composed by a prior AssignMessage step -->
      <Parameter ref='composed-key-for-kvm'/>
    </Key>
  </Get>
...

 

Thanks for your response. I will work on this and will update here soon. Appreciate your response.

@dchiesa1 : Your solution worked. Thanks a lot. I am in learning phase and I am really learning a lot here.