admin管理员组文章数量:1022997
I have an option set field in Dynamics CRM that has two values: "In Progress" (default) and "Completed". Using JavaScript, I want to issue a confirm box that triggers during the field event OnChange. The confirm box warns the user that if the user has selected "Completed" it will lock all the other fields in the record.
Anyway, I wrote my code such that the confirm box will set the value of the option set. For some reason, it is not changing the values of the field. If the user clicks "Completed" and when the user clicks 'Cancel' in the confirm box to confirm and validate, it would still set the field value to "Completed". Any reason why it would not set the field values? Here is my code:
function confirmTaskStatus() {
if (Xrm.Page.getControl("moc_taskstatus").getDisabled()){
var taskStatusValue;
var message = "Do you want to set this Task to Completed?
You cannot edit, change or add anything to the Project Task fields
once it is set to Completed";
if (confirm(message) == true) {
taskStatusValue = 223770000; // Display Label = "Completed"
Xrm.Page.getControl("moc_taskstatus").setDisabled(true);
} else {
taskStatusValue = 223770001; // Display Label = "In Progress"
}
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
}
}
function saveTaskStatus() {
window.setTimeout(confirmTaskStatus, 1000);
}
Have mercy on me; I'm still quite new to scripting and Dynamics CRM.
I have an option set field in Dynamics CRM that has two values: "In Progress" (default) and "Completed". Using JavaScript, I want to issue a confirm box that triggers during the field event OnChange. The confirm box warns the user that if the user has selected "Completed" it will lock all the other fields in the record.
Anyway, I wrote my code such that the confirm box will set the value of the option set. For some reason, it is not changing the values of the field. If the user clicks "Completed" and when the user clicks 'Cancel' in the confirm box to confirm and validate, it would still set the field value to "Completed". Any reason why it would not set the field values? Here is my code:
function confirmTaskStatus() {
if (Xrm.Page.getControl("moc_taskstatus").getDisabled()){
var taskStatusValue;
var message = "Do you want to set this Task to Completed?
You cannot edit, change or add anything to the Project Task fields
once it is set to Completed";
if (confirm(message) == true) {
taskStatusValue = 223770000; // Display Label = "Completed"
Xrm.Page.getControl("moc_taskstatus").setDisabled(true);
} else {
taskStatusValue = 223770001; // Display Label = "In Progress"
}
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
}
}
function saveTaskStatus() {
window.setTimeout(confirmTaskStatus, 1000);
}
Have mercy on me; I'm still quite new to scripting and Dynamics CRM.
Share Improve this question edited Jun 16, 2016 at 23:08 12341234 asked Jun 16, 2016 at 22:58 1234123412341234 4046 silver badges16 bronze badges1 Answer
Reset to default 6It looks like the control is disabled (by looking at your code snippet).
Disabled attributes SubmitMode
is set to false, meaning, CRM will ignore any updates to the attribute unless you force CRM to save it by calling SetSubmitMode after the value is updated.
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
Xrm.Page.getAttribute("moc_taskstatus").setSubmitMode('always');
I have an option set field in Dynamics CRM that has two values: "In Progress" (default) and "Completed". Using JavaScript, I want to issue a confirm box that triggers during the field event OnChange. The confirm box warns the user that if the user has selected "Completed" it will lock all the other fields in the record.
Anyway, I wrote my code such that the confirm box will set the value of the option set. For some reason, it is not changing the values of the field. If the user clicks "Completed" and when the user clicks 'Cancel' in the confirm box to confirm and validate, it would still set the field value to "Completed". Any reason why it would not set the field values? Here is my code:
function confirmTaskStatus() {
if (Xrm.Page.getControl("moc_taskstatus").getDisabled()){
var taskStatusValue;
var message = "Do you want to set this Task to Completed?
You cannot edit, change or add anything to the Project Task fields
once it is set to Completed";
if (confirm(message) == true) {
taskStatusValue = 223770000; // Display Label = "Completed"
Xrm.Page.getControl("moc_taskstatus").setDisabled(true);
} else {
taskStatusValue = 223770001; // Display Label = "In Progress"
}
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
}
}
function saveTaskStatus() {
window.setTimeout(confirmTaskStatus, 1000);
}
Have mercy on me; I'm still quite new to scripting and Dynamics CRM.
I have an option set field in Dynamics CRM that has two values: "In Progress" (default) and "Completed". Using JavaScript, I want to issue a confirm box that triggers during the field event OnChange. The confirm box warns the user that if the user has selected "Completed" it will lock all the other fields in the record.
Anyway, I wrote my code such that the confirm box will set the value of the option set. For some reason, it is not changing the values of the field. If the user clicks "Completed" and when the user clicks 'Cancel' in the confirm box to confirm and validate, it would still set the field value to "Completed". Any reason why it would not set the field values? Here is my code:
function confirmTaskStatus() {
if (Xrm.Page.getControl("moc_taskstatus").getDisabled()){
var taskStatusValue;
var message = "Do you want to set this Task to Completed?
You cannot edit, change or add anything to the Project Task fields
once it is set to Completed";
if (confirm(message) == true) {
taskStatusValue = 223770000; // Display Label = "Completed"
Xrm.Page.getControl("moc_taskstatus").setDisabled(true);
} else {
taskStatusValue = 223770001; // Display Label = "In Progress"
}
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
}
}
function saveTaskStatus() {
window.setTimeout(confirmTaskStatus, 1000);
}
Have mercy on me; I'm still quite new to scripting and Dynamics CRM.
Share Improve this question edited Jun 16, 2016 at 23:08 12341234 asked Jun 16, 2016 at 22:58 1234123412341234 4046 silver badges16 bronze badges1 Answer
Reset to default 6It looks like the control is disabled (by looking at your code snippet).
Disabled attributes SubmitMode
is set to false, meaning, CRM will ignore any updates to the attribute unless you force CRM to save it by calling SetSubmitMode after the value is updated.
Xrm.Page.getAttribute("moc_taskstatus").setValue(taskStatusValue);
Xrm.Page.getAttribute("moc_taskstatus").setSubmitMode('always');
本文标签: JavascriptMS Dynamics CRM 2016 Changing value of option set field using confirm boxStack Overflow
版权声明:本文标题:JavascriptMS Dynamics CRM 2016: Changing value of option set field using confirm box - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745579212a2157208.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论