是否有一种方法可以将Dynamics CRM中的字段作为一次输入字段?

问题描述 投票:0回答:3

基本上,我想要的是用户应该能够选择下拉菜单,并且在做出选择并保存选择之后不能更改它。因此它将是one-time输入字段。

下面是我要应用此属性的字段的屏幕截图。

photo

因此此字段具有YesNo选择。为了使业务逻辑免于失败,我必须将其设置为一次性输入字段。

我在表单编辑器中查找了可能的内容,但是找不到任何可以实现此目的的内容。

更新#1

下面是我的onload函数:

function Form_onload() {
    var formType = Xrm.Page.ui.getFormType();
    var p = Xrm.Page.getAttribute("zt_parentopportunityid");
--------------NEW CODE--------------------------------

    if(formType ==2){ //form type 2 means the form is a saved form. form type 1 is new form.

    alert(formType);
    var myattribute = Xrm.Page.getAttribute("arise_internal");
    var myname = myattribute.getName();
    if (Xrm.Page.getControl(myname) != null) {
        //alert(myname);
        Xrm.Page.getControl(myname).setDisabled(true);
    }
    }
--------------NEW CODE---------------------------
    if (formType == 1 && p != null && p.getValue() != null) {
        alert('Child Opportunities can only be created by clicking the Create Child Opportunity button in the Opportunity ribbon.');
        window.top.close();
    }

    CheckType();
    CheckClasses();
    var sowGenerationDateAttr = Xrm.Page.getAttribute("arise_sowmastergenerationdate");
    var sowGenerationDateValue = sowGenerationDateAttr.getValue();
    setSOWAttributesRequired(!(sowGenerationDateValue == undefined || sowGenerationDateValue == null));

    if (Xrm.Page.ui.getFormType() == 1) {
        var ctio = Xrm.Page.getControl("zt_classtypesincluded");
        if (ctio != null) {
            ctio.setDisabled(false);
        }

        //for Enrollment Voice Assessment Setting the default value to 3 - feature 10476
        var fail = Xrm.Page.getControl("arise_voiceassessmentexpirymonthfail");
        var pass = Xrm.Page.getControl("arise_voiceassessmentexpirymonthpass");

        if (fail != null)
            Xrm.Page.getAttribute("arise_voiceassessmentexpirymonthfail").setValue(3);

        if (pass != null)
            Xrm.Page.getAttribute("arise_voiceassessmentexpirymonthpass").setValue(3);
    }
}
dynamics-crm microsoft-dynamics dynamics-crm-2013
3个回答
0
投票

没有针对此类自定义要求的OOB配置,但是我们可以应用一些脚本逻辑。

假设这是一个默认值为nullpicklist,而不是two-option bool field,我们可以使用onLoad表单脚本检查其值并锁定它。不需要onChange功能。

如果是布尔字段,那么很难实现。您必须跟踪初始值和为实现所需逻辑所做的更改。或通过某些unsupported code


0
投票

无代码解决方案:我认为您可以使用带有Yes / No选项和默认值Unassigned Value的Option集。然后将该字段添加到“允许更新”设置为“否”的字段级别安全中。

Field Level Security with no update

更新FLS字段权限时,请确保配置文件与组织“团队”相关联,以便所有用户都可以看到该字段:

enter image description here


0
投票

Arun已经给您提示如何进行操作,我只是在我的一个实例上尝试了此要求。

就我而言,我创建了一个额外的字段(虚拟字段)new_hasfieldbeenchanged1更改字段时,此字段将保存数据。锁定此字段(始终)并将该字段保留在表单上(但可见= false)

现在您需要2个触发器Onload和OnSave。下面的功能将完成您​​的工作。让我知道是否有帮助。

function onLoad(executionContext) {

    debugger;
    var formContext;
    if (executionContext && executionContext.getFormContext()) {
        formContext = executionContext.getFormContext();
        //executionContext.getEventSource()
        if (formContext.getAttribute("new_hasfieldbeenchanged1") && formContext.getAttribute("new_hasfieldbeenchanged1").getValue()!=null) {
            if (formContext.getControl("new_twooptionfield")) {
                formContext.getControl("new_twooptionfield").setDisabled(true);
            }
        }
    }
}
function onSave(executionContext) {
    debugger;
    var formContext;
    if (executionContext && executionContext.getFormContext()) {
        formContext = executionContext.getFormContext();
        //executionContext.getEventSource()
        if(formContext.getAttribute("new_hasfieldbeenchanged1") && formContext.getAttribute("new_twooptionfield") && formContext.getAttribute("new_twooptionfield").getIsDirty()){
            formContext.getAttribute("new_hasfieldbeenchanged1").setValue((new Date()).toString());
            if (formContext.getControl("new_twooptionfield")) {
                formContext.getControl("new_twooptionfield").setDisabled(true);
            }
        }

    }
}
© www.soinside.com 2019 - 2024. All rights reserved.