Hi,
I'm looking for a way to get the remote ip address (of the user logged in). Is there a way to do this at the serverside, in a trigger for example? Without hosting a JSP file which fetches this.
I want to track from what IP address an object is created from in a onCreate trigger.
Regards,
Harrie.
Hi Harrie,
You can get IP address from client side to server side using Html events. But it requires user interaction. Just sharing my thought, I am not sure it works for you.
Steps:
1) Create a text box field
2) Click on Events link of above-created textbox(Object Definition -> Fields section)
3) Enter "myIP();" as value for onfocus event
4) Move to new record page
5) Click on Design this page
6) Add script component
7) Paste below script & save
<script>
function myIP() {
ajaxRreq = rbf_getXMLHTTPRequest();
if (ajaxRreq) {
ajaxRreq.open('GET', 'https://api.ipify.org', false);
ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');
ajaxRreq.send();
document.getElementById("IPAddresssText").value = ajaxRreq.responseText.toString();
}
}
</script>
8) While creating new record focus once on above created text box. It will fetch the IP address and set the value
9) Save the record.
Thanks
Srinivas
Nobody? :-/
Flag this post as spam/abuse.
I agree: this is not possible with current framework.
Hi Harrie,
Server-side, you can use the code creating a trigger type “Update Field Value”:
rbv_api.sendJSONRequest("https://api.ipify.org", null, "GET", "application/text; charset=UTF-8" , null, null, null);
Client-side, you can use the code inside a script component:
<script>
function myIP() {
ajaxRreq = rbf_getXMLHTTPRequest();
if (ajaxRreq) {
ajaxRreq.open('GET', 'https://api.ipify.org', false);
ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');
ajaxRreq.send();
document.getElementById("ip").innerHTML = ajaxRreq.responseText.toString();
}
}
</script>
<div id="ip"> <script> myIP(); </script></div>
It’ll return the user IP on server-side and/or client-side ...
Regards,
Ricardo
Clever! Thanks Ricardo!
Thanks! I will try the clientside approach, since I will get back the server's ip address instead of the users ip address using the serverside code.
Getting the users ip address needs a custom JSP I think.
Regards,
Harrie.
Hi Harrie,
You can get IP address from client side to server side using Html events. But it requires user interaction. Just sharing my thought, I am not sure it works for you.
Steps:
1) Create a text box field
2) Click on Events link of above-created textbox(Object Definition -> Fields section)
3) Enter "myIP();" as value for onfocus event
4) Move to new record page
5) Click on Design this page
6) Add script component
7) Paste below script & save
<script>
function myIP() {
ajaxRreq = rbf_getXMLHTTPRequest();
if (ajaxRreq) {
ajaxRreq.open('GET', 'https://api.ipify.org', false);
ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');
ajaxRreq.send();
document.getElementById("IPAddresssText").value = ajaxRreq.responseText.toString();
}
}
</script>
8) While creating new record focus once on above created text box. It will fetch the IP address and set the value
9) Save the record.
Thanks
Srinivas