Pages

Monday 24 June 2013

set value in text field using javascript in crm 2011

How to set value in text field using javascript in crm 2011

function setValueOnload()
{
    Xrm.Page.data.entity.attributes.get("fax").setValue("FAX12345");
    Xrm.Page.data.entity.save();   
}
   (or)
function setValueOnload()
{
    Xrm.Page.getAttribute("fax").setValue("FAX12345");
    Xrm.Page.data.entity.save();
}

5 comments:

  1. Please advise on how do I set value in a currency value?

    ReplyDelete
  2. Hi..

    Currency is lookup field.so you can set currency value like this way.

    function setCurrency(){
    var currencyid = "B52275BE-28F4-E211-9160-984BE1734553";
    var currencyName = "US Dollar";
    var entityName = "transactioncurrency";
    Xrm.Page.getAttribute("transactioncurrencyid").setValue([{ id: currencyid, name: currencyName, entityType: entityName}]);
    }

    You can call this function in onload event in any entity like contact,account etc.

    ReplyDelete
  3. how can I copy a date field into a text box

    ReplyDelete
  4. Hello...

    I have a custom entity where i have a contact lookup field where the user selects a contact. I would like to update a field on that custom form/entity with data from a field from the contact record. Any help would be appreciated!!

    ReplyDelete