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");
}
If you have any doubt in the post please post comments. I will try to solve your problem.
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");
}
hi, but this is not working in crm2015 when we turn off the legacy render option.
ReplyDeleteYes it should not work in CRM 2015 update 1 But will work in CRM 2015
DeletePositive 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.
ReplyDeletedefer parsing of js wordpress
What a good blog you have here. Please update it more often. This topics is my interest. Thank you. . .
ReplyDeleteTropic Diva