Write user IP address to a field using a URL-Formula

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

Does anyone have some code for a URL-formula field to capture a user's IP address and write it to a text field in the same table? I've tried a number of ways to do it and can't figure it out. Thanks.

Photo of Mark

Mark

  • 40 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
You have to use script and obtain the IP address from an external web service such as ipify which returns jsonp (or support CORS):

ipify
https://api.ipify.org/?format=jsonp


Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=369


The code in the above pastie will put the ip address in the field with by fid=6.

This code is be used with the image onload technique.

Also note that this script is using a free web service which may code and go so if it stops working at some time it is likely that the web service was over quota or was taken down.
Photo of Mark

Mark

  • 40 Points
I understand the code and the source of the ip address but I don't understand the right way to insert the javascript into the url-formula field to make it work.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
Read the [Notes] in the pastie and follow the links for instructions.