fetch the form id using javascript RRS feed

  • Question

  • Hi

    I have an entity having many form types. whenever i change the form type i need to fetch the form id and 
    update it in a field everytime the form time changes.How can i do this using javascript.

    Thanks in advance.

    Tuesday, December 9, 2014 5:53 AM


  • Hi Amy,

    Use the below code:-

    function showFormItems()
    // To get Current opened form Id and label
        var item = Xrm.Page.ui.formSelector.getCurrentItem();
        var itemLabelValue = item.getLabel();
        var itemIdValue = item.getId();

    //To get all forms for an entity

        var items = Xrm.Page.ui.formSelector.items.get();
        for (var i in items)
            var item = items[i];
            var itemId = item.getId();
            var itemLabel = item.getLabel();       

    //To set it in a field
        Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’);  

    Put this function on form load. And check the value set in the field. If different then set it to new value.

    Hope this helps!!!



    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Tuesday, December 9, 2014 6:20 AM