Journey Manager (JM)
The transaction engine for the platform. |
Form Builder Platform Developer | All versions
This feature is related to all versions.
It may be necessary in certain instances to determine the IP address of the user who has requested a form, for example, so that internal users can view a different version of a form than external users, or so that users in different countries or areas see different form content.
The form must be pre-populated with either the IP address of the requesting user, or an indicator of what type of user they are, which has been determined using the IP address in a pre-populated Groovy script.
You can do this in Manager:
// Script parametes include: form (Form), formRequestParams (Map<String, Object>), request (HttpServletRequest), schemaSeed (Document), userAccountId (String), serviceDefinition (ServiceDefinition), serviceParameters (Map<String, String>)
// Script return : Form XML data string value or return empty value and update the schemaSeed Document parameter
def returnXml = '''
<prefillData>
<value1>''' + request.getRemoteAddr() + '''</value1>
<value2>''' + request.getHeader("X-Forwarded-For") + '''</value2>
</prefillData>
''';
return returnXml;
request.getRemoteAddr()
Depending how the TransactionManager server is set up, this may not always give you the user’s address. For example, tm.demo.avoka.com sits behind a load balancer, which catches the user’s HTTP request and uses it to create a new one. Using the above code will return the IP address of the load balancer, rather than the user. In this instance, the user’s IP address must be accessed through the HttpServletRequest object’s header, using the code:
request.getHeader(“X-Forwarded-For”)
Next, learn how to view Transact functions.