使用JavaScript在具有相同ID名称的同一表单上显示/隐藏多个字段 [英] Using JavaScript to Show/Hide multiple fields on the same form with same id name

查看:117
本文介绍了使用JavaScript在具有相同ID名称的同一表单上显示/隐藏多个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在同一Dynamics CRM表单上填写字段。一个是帐户名,另一个是公司。它们都共享相同的字段id名称,即parentcustomerid。我需要基于另一个字段的选项集的值来显示/隐藏这些字段。我可以显示/隐藏帐户名字段,但公司字段不会显示/隐藏。

I have to fields on the same Dynamics CRM form. One is Account Name and the other field is Company. They both share the same field id name which is parentcustomerid. I need to show/hide these fields based on the value of an option set of another field. I can get the Account name field to show/hide but the Company field will not show/hide.


函数showHideSourceField(){

function showHideSourceField() {

var type = Xrm.Page.data.entity.attributes.get("new_type").getValue();
var source = Xrm.Page.ui.controls.get("new_source");
var accountname = Xrm.Page.ui.controls.get("parentcustomerid");
var company = Xrm.Page.ui.controls.get("parentcustomerid");

//Type of Contact is Unaffiliated
if (type == 100000004) {

    source.setVisible(true);
    accountname.setVisible(false);
    company.setVisible(false);



推荐答案

您有两个可能性:

1)它们是两个不同的字段,您可以在表单编辑器中简单地进行检查,例如一个是 name 另一个是 parentcustomerid

1) They are two different fields, and you can simply check this in the form editor, for example one is name the other is parentcustomerid

2)它们是同一字段,两次添加到表单中,可以在Dynamics CRM中使用,在这种情况下,第一个字段为 parentcustomerid ,第二个字段为 parentcustomerid1 ,您仍然可以检查表单编辑器中的字段是否相同。

2) They are the same field added twice to the form, this is possible inside Dynamics CRM, in this case the first field is parentcustomerid an the second is parentcustomerid1, and you can still check if it is the same field inside the form editor.

这篇关于使用JavaScript在具有相同ID名称的同一表单上显示/隐藏多个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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