locked
how to get value from HTML DOM and set that value to CRM2011 attribute ? RRS feed

  • Question

  • hi,

    i retrieved attachment details using JSON andODATA query,

    function retrieveReqCallBack(retrieveReq) {
        if (retrieveReq.readyState == 4 /* complete */) {
            var retrieved = this.parent.JSON.parse(retrieveReq.responseText).d;
            
            var message = "";
            var fun_var =
            "<script type=text/javascript>" +
            "function ret_val()" +
            "{" +
            "for (var i=0; i < document.orderform.test.length; i++){if (document.orderform.test[i].checked){var rad_val = document.orderform.test[i].value;}}" +        
            "alert(rad_val);" +
            "}"+
            "</script>";
            for (var i = 0; i < retrieved.results.length; i++) 
            {
                message += " <input type='radio' name='test' value=' " + i + "' />" + retrieved.results[i].FileName + "<br />";
            }
            myWindow = window.open('', '', 'width=500,height=200,scrollbars=yes');
            myWindow.document.write(fun_var + "<form name='orderform'>" + message + "<input type='submit' onclick='ret_val()' value='Convert'/>" +"</form>");
            myWindow.focus();
        }
    }

    in the above code

    document.write will give radio buttons and a button. On click of that button, it will alert the value(rad_value in the above code) of the button which is checked.

    now my requirement is to retrieve the value of the radio button which is checked (rad_value )and set that value to the CRM2011 attribute.

    i would be thankful for your suggestions.


    • Edited by Wils.09 Wednesday, July 25, 2012 7:27 AM
    Wednesday, July 25, 2012 7:25 AM

All replies

  • Hi,

    Try to use below line from your web resource

    window.parent.Xrm.Page.getAttribute("FieldName").seetValue(true);


    Conatact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by MubasherSharif Wednesday, July 25, 2012 8:21 AM
    Wednesday, July 25, 2012 7:32 AM
    Moderator
  • hi,

    sorry, i couldn't understand your reply properly.

    when i execute the above im getting this

    when i click "Conver" button i can se the value of the radio button as alert using aboue code.

    how to set that value to the attribute ?

    Wednesday, July 25, 2012 7:43 AM
  • Hi,

    try to use above line in your function that you are calling on html button (convert) click.


    Conatact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by MubasherSharif Wednesday, July 25, 2012 8:21 AM
    Wednesday, July 25, 2012 7:59 AM
    Moderator
  • hi,

    i tried this. but not working.

    var fun_var =
            "<script type=text/javascript>" +
            "function ret_val()" +
            "{" +
            "for (var i=0; i < document.orderform.test.length; i++){if (document.orderform.test[i].checked){var rad_val = document.orderform.test[i].value;}}" +        
            //"alert(rad_val);" +
            "window.parent.Xrm.Page.getAttribute('new_dummy').setValue(rad_val);"+
            "this.window.close();" +
            "}"+
            "</script>";

    Wednesday, July 25, 2012 8:38 AM