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

Set value of two option field that's in focus w javascript

$
0
0

Hey everyone,

GOAL:

I have a function thats triggered on the change of a two option set.

If the user sets the value to false, they receive a prompt asking them for the reason behind this. If the user cancels or enters nothing. the field is set back to true.

ISSUE:

the value of gg_markfordeactivation will only ever be set back to true if the mouse hovers over the field. 

this also cause issues with the prompt entering a random never ending loop sometime. please help me here.

here is the code, line 25 is where the issue starts

function contactCancelationReason(executionContext) {'use strict';
    var formContext = executionContext.getFormContext(),
        mfdLogicalName = "gg_markfordeactivation",
        mfdField = formContext.getAttribute(mfdLogicalName),
        mfdValue = mfdField.getValue();

    // check to see if the field exists
    if (mfdField !== null) {

        // checks if mfd was set to false
        if (mfdValue === 0) {

            // pop to ask for reason 
            var reason;
            reason = prompt("Please decribe the reason why this record is not to be deleted...");
            // checks if a reason was enterd
            if (reason !== "null" || reason !== null || reason !== "") {
                // yes, send http request to create a note
            } else {
                // no, set mfd back to true
                Xrm.Page.getAttribute(mfdLogicalName).setValue(true);
                return;
            }
        }
    }
}


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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