首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检索快速查看表单值-动态客户关系管理JavaScript

问检索快速查看表单值-动态客户关系管理JavaScript
EN

Stack Overflow用户
提问于 2021-01-28 00:43:27
回答 1查看 317关注 0票数 0

对于功能的某个方面,我需要从实体“课程请求”表单上的快速查看表单中提取一个值。快速查看表单是“计划”实体的,包括会员和非会员价格的详细信息。

我需要检索“成员价格”值,并在父窗体上为该值设置一个相应的字段。我有下面的代码来做这件事,但是这似乎不起作用。

快速查看表单称为:课程:课程详细信息-快速查看

代码语言:javascript
复制
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;
    }
}
EN

回答 1

Stack Overflow用户

发布于 2021-01-28 10:11:00

请确保您使用的是快速查看表单的名称而不是标签,因为名称不能像您使用的那样有空格。

此外,您可能需要使用isLoaded方法来确保重试的完整渲染和setTimeout。Read more

代码语言:javascript
复制
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;
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65923547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档