web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Quick Campaign JavaScript Issue.

(0) ShareShare
ReportReport
Posted on by

I am troubleshooting an issue where creating Phone Call records from the Quick Campaign functionality in that now phone call records get created. Looking at the Phone Call form I see the following JavaScript that appears to be causing it to fail:

function retrieveUserReqCallBack(retrieveUserReq) 
{ 

if (retrieveUserReq.readyState == 4 /* complete */) 
{   
if (retrieveUserReq.status == 200) 
{  
var retrievedUser = this.parent.JSON.parse(retrieveUserReq.responseText).d;  
if (retrievedUser.FullName != null)   var setUservalue = new Array();  
setUservalue[0] = new Object();  
setUservalue[0].id = Xrm.Page.context.getUserId();  
setUservalue[0].entityType = 'systemuser';  
setUservalue[0].name = retrievedUser.FullName;

Xrm.Page.getAttribute('from').setValue(setUservalue)  
}
else 
{    
}  
} 
}

I didn't write this code but it appears that the line that updates the 'from' field is causing the Quick Campaign job to fail. Commenting out this function or just the line 'Xrm.Page.getAttribute('from').setValue(setUservalue)' allows the phone call records to be created.

Is there something wrong with the way the JavaScript is written or will this sort of thing never work with Quick Campaign?

*This post is locked for comments

I have the same question (0)
  • Royal King Profile Picture
    27,686 on at
    RE: Quick Campaign JavaScript Issue.

    The function you posted is a call back function to the main function.. It looks you are missing main function that makes call to service to retrieve the data.

  • James Ayling Profile Picture
    on at
    RE: Quick Campaign JavaScript Issue.

    You are correct. Here is all of it:

    function getSenderInfo() {  
    var context;
    var serverUrl;
    var UserID;
    var ODataPath;
    context = Xrm.Page.context;
    serverUrl = context.getServerUrl();
    UserID = context.getUserId();
    ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
    var retrieveUserReq = new XMLHttpRequest();
    retrieveUserReq.open("GET", ODataPath + "/SystemUserSet(guid'" + UserID + "')", true);
    retrieveUserReq.setRequestHeader("Accept", "application/json");
    retrieveUserReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    retrieveUserReq.onreadystatechange = function () {  retrieveUserReqCallBack(this);  };  retrieveUserReq.send();   }   
    
    function retrieveUserReqCallBack(retrieveUserReq) 
    { 
    
    if (retrieveUserReq.readyState == 4 /* complete */) 
    {   
    if (retrieveUserReq.status == 200) 
    {  
    var retrievedUser = this.parent.JSON.parse(retrieveUserReq.responseText).d;  
    if (retrievedUser.FullName != null)   var setUservalue = new Array();  
    setUservalue[0] = new Object();  
    setUservalue[0].id = Xrm.Page.context.getUserId();  
    setUservalue[0].entityType = 'systemuser';  
    setUservalue[0].name = retrievedUser.FullName;
    
    Xrm.Page.getAttribute('from').setValue(setUservalue)  
    }
    else 
    {    
    }  
    } 
    }
    


    I don't think the script is incorrect as such, just that it doesn't seem to co-exist with the Quick Campaign functionality.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans