web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How can create automatically showing Country,Time, Normal text field

(0) ShareShare
ReportReport
Posted on by

Hi  Experts

          Here one example image i create 2 feild on my form One is Address & another is Time when i write any name like USA , London then automatically next text field Time zone a normal text box show the current time i use some function but problem i done that previously done in HTML But i need this in crm please help me regarding this.

CaptureTIME.JPG 

Please help me regarding this

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: How can create automatically showing Country,Time, Normal text field

    Error like that 

  • Suggested answer
    DH kumar CRM Profile Picture
    1,345 on at
    RE: How can create automatically showing Country,Time, Normal text field

    Hi,

    can u pls post the code also to check in detail.

    i think the problem is also if you are using break keyword which is a reserved word. try changing that variable name from break to break1 the problem might go away....

  • Community Member Profile Picture
    on at
    RE: How can create automatically showing Country,Time, Normal text field

    LoadWebResource("/Script/google.js")

    LoadWebResource("/Script/timezone.js")

    //Function to Load webResource

    function LoadWebResource(resource) {

    var httpRequest = null;

    try {    

    if (window.XMLHttpRequest) {  // code for IE7+, Firefox, Chrome, Opera, Safari

    httpRequest = new XMLHttpRequest();

    }

    else {  // code for IE6, IE5

    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

    }

    var serverUrl= Xrm.Page.context.getServerUrl();

    if (serverUrl.match(/\/$/)) {

    serverUrl = serverUrl.substring(0, serverUrl.length - 1);

    }

    httpRequest.open("GET", serverUrl + "/webresources/" + resource, false);

    httpRequest.send(null);

    eval(httpRequest.responseText);

    }

    catch (e) {

    alert("LoadWebResource >> Error loading " + resource + ":\n" + e.description);

    }

    }

    //The Main Code is Started.

    function getCoordinates (address, success, fail)

    {    

    var geocoder = new google.maps.Geocoder ();

    geocoder.geocode ({ 'address': address }, function (results, status)

    {

    if (status == google.maps.GeocoderStatus.OK)

    {

    var latitude = results[0].geometry.location.lat ();

    var longitude = results[0].geometry.location.lng ();

    success ({ latitude: latitude, longitude: longitude });

    }

    else

    {

    fail ("Could not get coordinates for " + address);

    }

    });

    }

    //Second code

    function getTimezone (coords, success, fail)

    {

    var tz = new TimeZoneDB ();

    tz.getJSON (

    {

    key: "S7QKX1UTA0O0",

    lat: coords.latitude,

    lng: coords.longitude

    },

    function (data)

    {

    if (data.status == "OK")

    {

    var date = new Date ();

    date.setTime (data.timestamp * 1000);

    success (date);

    }

    else

    {

    fail (data.message);

    }

    });

    }

    //Third Code

    function displayLocalTimeForAddress ()

    {

    var address = document.getElementById ("new_addres").value;

    function display (date)

    {

       var s = date.toUTCString();

               var day = s.slice(0,3);

                       var t = s.substr(s.length - 12);

                       t = t.slice(0,5);

                       var h = parseInt(t.slice(0,2));

                       var am = "AM"

                       if (h > 12) {

                        h = h - 12;

                       am = "PM"

                       }

                       var m = t.substr(3,5);

                    Xrm.Page.data.entity.attributes.get("new_timezone").setValue  = alert ("Current local time at '" + address + "' is " + day + " " + h.toString() + ":" + m + " " + am ); }

    function fail (message)

    {

    alert ("Failed: " + message);

    }

    getCoordinates (address, function (coords)

    {

    getTimezone (coords, display, fail);

    },

    fail);

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans