Check attribute type/formats in CRM 2011 javascript.

By | July 15, 2013

Now we can check the attribute formats in CRM java script.

To do this you just need to use the function “getFormat”. This function returns a string value that represents formatting options for the attribute. You can refer the below code to check the format of different types of attributes.
functionGetFormatOfAttributes() {
    var attributeFormat;
    try {
        //Get the format of String
        attributeFormat = Xrm.Page.getAttribute(“name”).getFormat();
        alert(“The format of name is “ + attributeFormat);
        //Get the format of Email attribute
        attributeFormat = Xrm.Page.getAttribute(“emailaddress1”).getFormat();
        alert(“The format of emailaddress1 is “ + attributeFormat);
        //Get the format of the Date and Time attribute
        attributeFormat = Xrm.Page.getAttribute(“createdon”).getFormat();
        alert(“The format of createdon is “+ attributeFormat);
        //Get the format of Duration
        attributeFormat = Xrm.Page.getAttribute(“new_duration”).getFormat();
        alert(“The format of Duration is “+ attributeFormat);
        //Get the format of Date Only
        attributeFormat = Xrm.Page.getAttribute(“new_date”).getFormat();
        alert(“The format of new_date is “ + attributeFormat);
        //Get the format of Time Zone
        attributeFormat = Xrm.Page.getAttribute(“address1_utcoffset”).getFormat();
        alert(“The format of address1_utcoffset is “ + attributeFormat);
       //Get the format of Url
        attributeFormat = Xrm.Page.getAttribute(“websiteurl”).getFormat();
        alert(“The format of websiteurl is “+ attributeFormat);
        //Get the format of multi line text
        attributeFormat = Xrm.Page.getAttribute(“description”).getFormat();
        alert(“The format of description is “+ attributeFormat);
    catch (e) {
        alert(“GetFormatOfAttributes Err >> “ + e.description);

Leave a Reply

Your email address will not be published. Required fields are marked *