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

Using REST RetrieveRecord on activity entity to set recipient

$
0
0

From an Email, I want to retrieve a custom lookup field ("new_manager") from the regardingobjectid (incident) and set the value as a recipient on the email.

Trying to run debugger and it seems it doesn't even fire the successcallback function "setManager".

Any help would be appreciated.

//SET MANAGER TO EMAIL RECIPIENT

function retrieveManager(regardingobjectId) {
    if(!Xrm.Page.getAttribute("regardingobjectid").getValue())
        return;

    var regardingobjectId = Xrm.Page.getAttribute("regardingobjectid").getValue()[0].id;
    var EntitySchemaName = "Incident";

    if (regardingobjectId.entityType == "incident") {
        SDK.REST.retrieveRecord(
        regardingobjectId,
        EntitySchemaName,
        "new_manager", null,
        setManager, errorHandler);
    }
}
function setManager(incident) {
debugger;
    var manager = incident.new_manager;
        if (manager != null) {
    var partlistData = new Array();
    partlistData[0] = new Object();
    partlistData[0].id = manager;
    partlistData[0].name = manager.name;
    partlistData[0].entityType = "systemuser";
    Xrm.Page.getAttribute("to").setValue(partlistData);
}
} 
function errorHandler(error) { 
alert(error.message); 
}



Viewing all articles
Browse latest Browse all 79901

Trending Articles



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