web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

javascript button creation

(0) ShareShare
ReportReport
Posted on by

hello mates ,

i am using crm 2016 and i need to create a button using javascript instead of a field 

or without a field doesn't matter 

this was my code it doesn't work :( code is here :

function IssueReceiptButton(attribute_name){
if (document.getElementById(attribute_name) != null) {
var
var FieldID = "field" + attribute_name;
var elementID = document.getElementById(attribute_name + "_d");
var div = document.createElement("div");
div.style.width = "20%";
div.style.textAlign = "right";
div.style.display = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = '<button id="' + FieldID + '" type="button" style="margin-left: 4px; width: 50%; " >Add Me</button>';
document.getElementById(attribute_name).style.width = "80%";
document.getElementById(FieldID).onclick = function () {onbuttonclick(); };
var Ir = Xrm.Page.getAttribute("new_issuereceipt");

if(Ir.getValue() == null){
Xrm.Page.getAttribute("new_issuereceipt").setVisible(false);
}


}
}

please need ur support masters

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Thomas David Dayman Profile Picture
    11,323 on at

    Hi Hansoon,

    Below is some code which i have written which works (It involves using a field though):

    var atrname = 'header_process_psd_sendemail';
    	if (window.parent.document.getElementById(atrname) != null)
    	{
    		var fieldId = 'field' + atrname;
    		var elementId = window.parent.document.getElementById(atrname + '_d');
    		var div = window.parent.document.createElement('div');
    		div.style.width = '50%';
    		div.style.textAlign = 'right';
    		div.style.display = 'inline';
    		var childDiv = elementId.getElementsByTagName('div')[0];
    		childDiv.style.display = 'none';
    		elementId.appendChild(div, elementId);
    		div.innerHTML = '<button id="' + fieldId + '"  type="button" style="margin-left: 4px; background-color: #FF3C3C; width: 50%;" >Send Email</button>';
    		window.parent.document.getElementById(atrname).style.width = '100%';
    		window.parent.document.getElementById(fieldId).style.background = '#FF3C3C';
    		window.parent.document.getElementById(fieldId).onclick = function ()
    		{
    			//do stuff
    		};
    	}


  • Community Member Profile Picture
    on at

    thanks Thomas

    actually i tried this code but it makes no sense neither error nor functionate !!

    i tried to on two different events onChange and onLoad and still no sense !

    any other idea bro ?

  • Thomas David Dayman Profile Picture
    11,323 on at

    Hi Hansooon,

    Have you got Legacy Form Rendering turned on?

    System Settings > General > Use Legacy Form Rendering

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans