I am working on CRM 2011. On Form_onLoad event I am presetting the value of a field.

mdg.PreSetField("address1_line1","Amsterdam");

but after clicking on save button my field address1_line1 is blank.

To check I put a alert on Form_onsave function.

alert("address =" + (Xrm.Page.getAttribute("address1_line1").getValue()));

In alert,I get the value of address1_line1 field but finally address1_line1 is blank.

mdg.PresetField function is as follows

mdg.PreSetField = function(attributeName, value) {
    var attribute;
    if (attributeName.setSubmitMode) {
        attribute = attributeName;
    }
    else {
        attribute = Xrm.Page.getAttribute(attributeName);
    }

    attribute.setSubmitMode('never');
    attribute.setValue(value);
    attribute.addOnChange(function() {
        attribute.setSubmitMode('always');
    });
};
有帮助吗?

解决方案

I solved it..

in my custom mdg.PresetField function earlier code was

attribute.setSubmitMode('never');

I changed never to always and now it is working..

其他提示

mdg.PreSetField("address1_line1","Amsterdam");

This code is not part of the CRM JavaScript API so I assume it's a custom library? Have you added this script to the list of webresources available on the form? Also make sure it comes before the script you are trying to use it in.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top