FormParam is taking only one value in AssignMessage policy even though we set multiple values

We have the following AssignMessage Policy, wherein we are trying to set multiple values to a specific Form parameter “addressParam”.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Multiple-Values">
<DisplayName>Assign Validate Message</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="http" type="request">validate.request</AssignTo>
<Set>
<Verb>POST</Verb>
<Headers>
<Header name="Accept">application/json</Header>
</Headers>
<FormParams>
<FormParam name="etoken">{request.header.etoken}</FormParam>
<FormParam name="signature">{request.header.signature}</FormParam>
<FormParam name="addressParam">DOOR_NO</FormParam>
<FormParam name="addressParam">STREET_AND_AREA</FormParam>
</FormParams>
<Path/>
</Set>
</AssignMessage>

However, we notice that the “addressParam” is taking only the last value every time. Can you please let me know if there’s some way to ensure that “addressParam” can take multiple values ?

0 3 419
3 REPLIES 3

I found one possible way to achieve this by using the Assign Message policy:

1) In your AssignMessage policy "Assign-Multiple-Values", remove the last FormParam assignment, i,.,e,

<FormParamname="addressParam">STREET_AND_AREA</FormParam>


2) Next create a new AssignMessage Policy as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Validate-Message">
<DisplayName>Assign Validate Message</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request">validate.request</AssignTo>
<Add>
<FormParams>
<FormParam name="reqParams">DEVICE_ID_OPT</FormParam>
</FormParams>
</Add>
</AssignMessage>


Note: The "createNew" should be set to false, so that the same formparam can be added to existing the request variable "validate.request".

3) Ensure that this policy is executed right after your previous AssignMessage Policy

I have tried this locally and it worked for me. But I am sure that there must be other better ways to address this requirement.

It is an interesting problem. There is no clear spec on how to handle form parameters with the same name.

See http://stackoverflow.com/questions/2203430/posting-form-fields-with-same-name-attribute

http://webmasters.stackexchange.com/questions/9775/is-it-valid-to-have-multiple-form-input-elements-...

http://stackoverflow.com/questions/24059773/correct-way-to-pass-multiple-values-for-same-parameter-n...

Some people implement this with comma separated values for the same key, and some have multiple keys. I would be tempted to set the parameters in JavaScript if possible instead of having multiple A.M. policies.

@Sean Davis,

Thanks for your answer. You are right the other way to do this is to set the parameters in Javascript through which we can ensure there's only one JavaScript policy instead of multiple AssignMessage policies.