对于功能的某个方面,我需要从实体“课程请求”表单上的快速查看表单中提取一个值。快速查看表单是“计划”实体的,包括会员和非会员价格的详细信息。
我需要检索“成员价格”值,并在父窗体上为该值设置一个相应的字段。我有下面的代码来做这件事,但是这似乎不起作用。
快速查看表单称为:课程:课程详细信息-快速查看
function getPrice(){
if (Xrm.Page.getControl('Course: Programme Details - Quick View_Course: Programme Details - Quick View_programme_MemberPrice') != null)
{
var priceQuickControl = Xrm.Page.getControl('Course: Programme Details - Quick View_Course: Programme Details - Quick View_programme_MemberPrice');
var price = priceQuickControl.getAttribute("memberprice").getValue();
//var newEmailfield = Xrm.Page.getAttribute("MemberPrice");
var priceCourseRequest = Xrm.Page.getAttribute("memberprice").setValue(price);
console.log(priceCourseRequest);
}
else{
return null;
}
}发布于 2021-01-28 10:11:00
请确保您使用的是快速查看表单的名称而不是标签,因为名称不能像您使用的那样有空格。
此外,您可能需要使用isLoaded方法来确保重试的完整渲染和setTimeout。Read more
function getAttributeValue(executionContext) {
var formContext = executionContext.getFormContext();
var quickViewControl = formContext.ui.quickForms.get("<QuickViewControlName>");
if (quickViewControl != undefined) {
if (quickViewControl.isLoaded()) {
// Access the value of the attribute bound to the constituent control
var myValue = quickViewControl.getControl(0).getAttribute().getValue();
console.log(myValue);
// Search by a specific attribute present in the control
var myValue2 = quickViewControl.getControl().find(control => control.getName() == "<AttributeSchemaName>").getAttribute().getValue();
console.log(myValue2);
return;
}
else {
// Wait for some time and check again
setTimeout(getAttributeValue, 10, executionContext);
}
}
else {
console.log("No data to display in the quick view control.");
return;
}
}https://stackoverflow.com/questions/65923547
复制相似问题