Search This Blog

Wednesday, November 25, 2015

Create button in CRM form using javascript with field

Create button in CRM form using javascript with field

If you have any doubt in the post please post comments. I will try to solve your problem.

Step 1:-Add a new attribute of type single line text in CRM form or you may use existing one.

Step 2: Add the fallowing code to your crm java script web resource. And call this function in the form onload.

function MakeButton() { 
        var atrname ="YOUR ATTRIBUTE SCHEMA NAME";// "new_stringtest";
        if (document.getElementById(atrname ) != null) {
        var fieldId = "field" + atrname ;
        if (document.getElementById(fieldId ) == null) {
            var elementId = document.getElementById(atrname + "_d");
            var div = document.createElement("div");
            div.style.width = "100px";
            div.style.textAlign = "right";
            div.style.display = "inline";
            elementId .appendChild(div, elementId );
            div.innerHTML = '<button id="' + fieldId + '"  type="button" style="margin-left: 3px; width: 100%;" >CRM Form Button</button>';
            document.getElementById(atrname).style.width = "0%";
            document.getElementById(fieldId ).onclick = function () { YourOnClickFunction(); };
        }
    }
}

function YourOnClickFunction(){
alert("Hi");

}

4 comments:

  1. hi, but this is not working in crm2015 when we turn off the legacy render option.

    ReplyDelete
    Replies
    1. Yes it should not work in CRM 2015 update 1 But will work in CRM 2015

      Delete
  2. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
    defer parsing of js wordpress

    ReplyDelete
  3. What a good blog you have here. Please update it more often. This topics is my interest. Thank you. . .
    Tropic Diva

    ReplyDelete

Note: Only a member of this blog may post a comment.