制作有关CRM 2011表格的部分 [英] MAking a section on CRM 2011 form required

查看:86
本文介绍了制作有关CRM 2011表格的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在必填表格上做一个部分。基本上,这些部分具有复选框。用户应该检查至少一个。

I want to make a 'section' on the form required. Basically the sections has checkboxes. The user is supposed to check atleast one. How can this be done?

推荐答案

在您的 OnSave 事件内部检查是否至少选中了一个复选框,如果未全部选中,则可以停止保存事件。

Inside your OnSave event you need to check if at least one checkbox is checked, if all are not selected you can stop the save event.

要停止保存事件,您需要将上下文传递给您onsave事件:

To stop the save event you need to pass the context to your onsave event:

函数如下:

function onSave(executionObj)
{
// stop the save event
executionObj.getEventArgs().preventDefault();
}

检查值有几种方法,最简单的方法是它们的数组:

to check the values you have several ways, the simplest one is to keep an array of them:

function onSave(executionObj)
{
   var canSave = false;
   var fields = ["new_checkbox1", "new_checkbox2", "new_checkbox3"];
   for (index = 0; index < fields.length; index++)
   {
      var checkboxValue = Xrm.Page.getAttribute(fields[index]).getValue();
      if (checkboxValue == true)
      {
         canSave = true;
         break;
      }
   }
   if (canSave == false)
   {
      alert("At least one checkbox must be selected!");
      executionObj.getEventArgs().preventDefault();
   }
}

这篇关于制作有关CRM 2011表格的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆