javascript - Xrm.Navigation.openForm 自动从前一个表单设置查找字段
问题描述
我在“Parcours”表单中添加了一个新按钮,该按钮将我带到另一个表单“问题”,其中包含Xrm.Navigation.openForm
“问题”表单有一个来自“Parcours”的查找字段,我想从以前的表单中自动填充它,例如:
这是我的按钮代码,我想自动检测 parcours 的 ID 并将其设置为新的“问题”表单
function NavigateQuestion(){
var entityFormOptions = {};
entityFormOptions["entityName"] = "zs_question";
var formParameters = {};
// Set lookup column
formParameters["zs_parcours"] = ""; // I want to put the ID here from the previous form.
formParameters["zs_parcoursname"] = ""; // Name of the parcours.
formParameters["zs_parcourstype"] = "zs_parcours"; // Table name.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
console.log(success);
console.log(formParameters);
},
function (error) {
console.log(error);
});
}
解决方案
您应该能够从当前记录表单本身获取值并进行分配。
确保为最新的客户端 API 方法传递 formContext(我将语法放在注释代码部分)。
// Set lookup column
formParameters["zs_parcours"] = Xrm.Page.data.entity.getId(); // or by using form context -- formContext.data.entity.getId();
formParameters["zs_parcoursname"] = Xrm.Page.getAttribute("zs_name").getValue(); // or by using form context -- formContext.getAttribute("zs_name").getValue();
formParameters["zs_parcourstype"] = "zs_parcours";
推荐阅读
- python - 如何将不知道的日期时间字符串转换为带时区的有意识的日期时间对象?
- html - 如何从 Reddit 修复损坏的嵌入链接
- arrays - 在 Laravel 中使用 where 子句从数组列中查询
- java - 如何将字符串转换为 JSON?
- elasticsearch - 与 Elastic Search 6 和 php ClientBuilder 完全匹配
- aws-lambda - 在 serverless.yaml 上出现以下错误:无法读取块映射条目;多行键可能不是隐式键
- jakarta-ee - 可以在没有 DI 容器的情况下使用 Jersey 吗?
- java - 当所有其他精灵都移动时,为什么 Carpaint 不移动?
- javascript - style.marginLeft 在 wordpress 中不起作用
- reactjs - 收到“警告:‘NaN’ 是‘background’ CSS 样式属性的无效值。” 错误