locked
Get IP address on formLoad RRS feed

  • Question

  • Hi,

         I want to to get the Ip address of client machine on Form Load. For this I am using the following code.

     

    var ip= ‘<!–#echo var=”REMOTE_ADDR”–>’;

    alert(“Your IP Address is :”+ip+” “);

    bu this code is not working.

    Please any one can help me. answer will be appreciated.

    Thank you.

     

     

    Thursday, October 7, 2010 10:23 AM

Answers

All replies

  • Javascript location host property returns the host address as domain name or IP of the host.

    alert(window.location.host);
    alert(window.location.hostname);

     

    Thursday, October 7, 2010 10:50 AM
  • Javascript location host property returns the host address as domain name or IP of the host.

    alert(window.location.host);
    alert(window.location.hostname);

     


    This will give host of a server but not your own IP Address.

    I checked your info and it seems that it is impossible to get IP address from JavaScript without any coding. What you can do is to combine following 2 solutions:

    1. http://a33ik.blogspot.com/2010/04/crm-usage-report.html - describes how to get client IP Address on a server side.

    2. http://a33ik.blogspot.com/2009/08/how-to-retrieve-server-datetime-on.html - describes how to pass some data from server to the client using Execute message.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, October 7, 2010 11:15 AM
    Moderator
  • Thanks for your reply Vinoth but this code give the IP address of server host not the client who is accessing the CRM.

    Can I  get the organization name also using same code. 

    Thursday, October 7, 2010 11:36 AM
  • Ya, i msunderstood your requirement.

    You can use ORG_UNIQUE_NAME to get Organization name. 

    alert("ORG_UNIQUE_NAME="+ORG_UNIQUE_NAME);

    You can also use prependOrgName

    var url = prependOrgName("/isv/app/myapp.aspx");

    Thursday, October 7, 2010 11:46 AM
  • Thank you Very much Vinoth.

    Sorry  to trouble you more.But, can you tell me the way to get entity name using Java script.

    Thursday, October 7, 2010 11:59 AM
  • ObjectTypeName will give you the name.

    alert(crmForm.ObjectTypeName);

    • Marked as answer by Jim Glass Jr Thursday, October 7, 2010 5:46 PM
    Thursday, October 7, 2010 12:06 PM
  • If this script will be placed somewhere inside entity form handlers - it will give you entity name:

    alert(crmForm.ObjectTypeName);


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, October 7, 2010 12:08 PM
    Moderator
  • Thank you Andriy and Vinoth, it is working.
    Thursday, October 7, 2010 12:09 PM