+ Start a Discussion
Manjunath T NManjunath T N 

How to get the IP address of the user's system in apex when they try to create a case?

Hi, I am facing an issue with cases, recently they were a lot of spam cases that have been created from web to case.
and this is not the first time it happened earlier also. So we have created validation rule on case to avoid spamming based on the subject, body, sender, etc but it's just a temporary solution because every time we receive a different kind of data, as soon as we get to know about spamming we are checking the values and adding those values in the validation rules to avoid further case creation.

But now we have come up with the below solution.

Creating an IP address field on case object, on the creation of case in salesforce we are saving the IP address of the system which we received the data from. so our motto is whenever more cases are created from the same IP address (10+ cases within 24 hours from the same IP address) then we are going to block that IP address temporarily. So I think by implementing this we can prevent spam cases creation in salesforce.

Question is:

How to get the IP address of the user's system in apex when they try to create a case?