简体   繁体   English

禁用选项列表字段功能会重置值 Dynamics crm 4.0 Javascript

[英]Disabling picklist field function resets value Dynamics crm 4.0 Javascript

My situation is that I have a field new_outcome that is a picklist with default value of null .我的情况是我有一个字段new_outcome ,它是一个默认值为null的选项列表。 Up on changing this field and selecting a value the field and its associated fields then needs to be locked and disabled.在更改此字段并选择一个值后,该字段及其相关字段需要被锁定和禁用。 Up on reopening the record this script is to run again and the field remain disabled.在重新打开记录时,此脚本将再次运行并且该字段保持禁用状态。 This is working fine in that when selecting the value the function is called and the field becomes disabled.这工作正常,因为在选择值时调用函数并且该字段被禁用。 The issue is upon reopening the record, the function is called but the if clauses don't meet the criteria because the new_outcome picklist field is back to a null value so is therefore no longer disabled.问题是在重新打开记录时,该函数被调用,但 if 子句不符合条件,因为new_outcome选择列表字段恢复为空值,因此不再被禁用。 I'm guessing this is to do with needing to force submit the new_outcome value but I can't seem to get it to work.我猜这与需要强制提交new_outcome值有关,但我似乎无法让它工作。

Sample without the forcesubmit :没有forcesubmit

  Stage2Lock = function()
{
if ((crmForm.all.new_outcome.DataValue != null) && (crmForm.all.casetypecode.DataValue == 1))
{
crmForm.all.new_extensionreason.Disabled =true;
crmForm.all.new_outcome.Disabled =true;
}
else
{
crmForm.all.new_extensionreason.Disabled =false;
crmForm.all.new_outcome.Disabled =false;
}
}

Any suggestions?有什么建议?

I think your suspicion is right.我觉得你的怀疑是对的。 One thing I have noticed in a number of forums is people not putting the action in Upper case, but it looks like you are doing that with Disabled (so I assume you are also doing that with ForceSubmit ).我在许多论坛中注意到的一件事是人们没有将操作放在大写中,但看起来您正在使用 Disabled 这样做(所以我假设您也在使用 ForceSubmit 这样做)。 Try updating the function to read as follows:尝试将函数更新为如下所示:

Stage2Lock = function()
{
if ((crmForm.all.new_outcome.DataValue != null) && (crmForm.all.casetypecode.DataValue == 1))
{
crmForm.all.new_extensionreason.Disabled =true;
crmForm.all.new_outcome.Disabled =true;
crmForm.all.new_extensionreason.ForceSubmit =true;
crmForm.all.new_outcome.ForceSubmit =true;
}
else
{
crmForm.all.new_extensionreason.Disabled =false;
crmForm.all.new_outcome.Disabled =false;
}
}

如何调用 crmForm.Save() 使值保持不变?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM