Notifications
Announcements
No record found.
Hello,
How can i create a button on entity form and also trigger event onclick on button using jscript
thanx.
*This post is locked for comments
To add button you can use Ribbon Workbench. To trigger onclick you can define JavaScript action on your button's command.
my script is,
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Metadata Demonstration</title>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script type="text/javascript">
function startSample() {
var select = document.getElementById("combobox");
select.onchange = function () {
var index = this.selectedIndex;
var selected = this.options;
var selectedValue= selected[index].text;
window.parent.Xrm.Page.getAttribute("jobtitle").setValue(selectedValue);
};
function clickSave(){
var Xrm = window.parent.Xrm;
Xrm.Page.data.entity.addOnSave(function (context) {
alert("Form was saved");
});
}
</script>
</head>
<body onload="startSample()">
<select id="combobox">
<option value="softwaredeveloper">Softvare Developer</option>
<option value="consultant">Microsoft Dynamics CRM Consultant</option>
<option value="busdeveloper">Business Developer</option>
</select>
<button onclick="clickSave()">
Save</button>
</body>
</html>
but Save button was not perform for save the record.
Try to use debugger to troubleshoot your code and figure out why method is not called.
Is he missing save?
Xrm.Page.data.save();
Not Working
Then check this article blogs.msdn.microsoft.com/.../debugging-custom-javascript-code-in-crm-using-browser-developer-tools and learn how to troubleshoot your code. Good luck.
Complete
I use simple code
function Save()
{
window.parent.Xrm.Page.data.entity.save();
Thanx..
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2