Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Javascript Function OnSave

$
0
0

Hi,

I was hoping someone could help guide me with my first javascript for Dynamics 365. I'm just trying to create an override field from a option set that would go into a text field. The text field does have a business in place to put the values needed. However, I need to add an override function for supervisors in the case they need it. I'm not getting any errors but I'm not getting the field it needs to setValue to to update. Here's my code and how I have the script setup in the form builder:

function supervisorFlagOverrideChanged(executionContext) {
    var formContext = executionContext.getFormContext();

    var supervisorFlagOverrideField = formContext.getAttribute("cr93a_SupervisorFlagOverride");
    var contactFlagsField = formContext.getAttribute("cmcps_ApplicationFlags");
    var contactFlagsControl = formContext.getControl("cmcps_ApplicationFlags");

    if (supervisorFlagOverrideField != null) {
        var supervisorFlagOverrideValue = supervisorFlagOverrideField.getValue();

        // Log supervisorFlagOverrideValue to console
        console.log("supervisorFlagOverrideValue: ", supervisorFlagOverrideValue);

            contactFlagsControl.setDisabled(false);
            contactFlagsField.setValue(supervisorFlagOverrideValue);
            contactFlagsControl.setDisabled(true);

            // Save the form.
            formContext.data.entity.save();
    } else {
        console.log("supervisorFlagOverrideField is null.");
    }
}
Ps. I left my debug in the code hoping that would help.

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>