문제

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