Thursday, March 20, 2014

Set Unresolved Email Id's in party List from Java Script

function setUnresolvedRecipient() {
    var unresolvedemail = "test@testing.com"

    if (unresolvedValue != null) {
        var obj = new Object(); //create the unresolved object
        obj.name = unresolvedemail;
        obj.category = 3;
        obj.data = unresolvedemail;
        obj.type = "9206";

        var toField = Xrm.Page.getAttribute("to");
        var toValue = toField.getValue();
        if (toValue != null) {
            toValue.push(obj); //if there are already other values, add to it
            toField.setValue(toValue);
        }
        else {
            toField.setValue([obj]); //if 'to' field is null, just override it
        }
        unresolvedField.setValue(null); //wipe the field after adding it to the 'to' list
    }
}

This will set the email "test@testing.com" in the To party list on the Email Activity

No comments:

Post a Comment