locked
CRM 2013. Add Queue to the "From" field RRS feed

  • Question

  • Hi,

    Trying to add the Queue to the Email "From" field

    SDK.JQuery.retrieveMultipleRecords(
    			"Queue",
    			"$filter=Name eq 'MyQueue'",
    			function (results) {
    				Xrm.Page.getAttribute("from").setValue(results[0]);
    				//Xrm.Page.getAttribute("from").setValue(results[0].Name);
    				//Xrm.Page.getAttribute("from").setValue(results[0].QueueId);
    			},
    			function (error) { alert(error) },
    			function () {}
    		);
    
    results[0] - returns object correct (checked in the debugger), but does not set it to the From field. Any suggestions?


    • Edited by Dismantled Friday, June 20, 2014 2:33 PM
    Friday, June 20, 2014 2:33 PM

Answers

  • function CorrectMail() {
    	SDK.JQuery.retrieveMultipleRecords(
    		"Queue",
    		"$select=QueueId,Name&$filter=Name eq 'MyQueue'",
    		function (results) {
    			
    			// Get some LookupControlItem to use as template
    			var tmpObject = Xrm.Page.getAttribute("ownerid").getValue();
    			
    			// Insert required data
    			tmpObject[0].ambiguousRecordsXml = undefined;
    			tmpObject[0].callback = "openlui(new Sys.UI.DomEvent(event))";
    			tmpObject[0].category = undefined;
    			tmpObject[0].data = undefined;
    			tmpObject[0].displayClass = "ms-crm-Lookup-Item";
    			tmpObject[0].entityType = "queue";
    			tmpObject[0].id = "{" + results[0].QueueId + "}";
    			tmpObject[0].name = results[0].Name;
    			tmpObject[0].onclick = undefined;
    			tmpObject[0].selected = undefined;
    			tmpObject[0].type = "2020";
    			tmpObject[0].typename = "queue";
    
    			// Put the Queue into the form
    			Xrm.Page.getAttribute("from").setValue([tmpObject[0]]);
    
    		},
    		function (error) { alert(error) },
    		function () {}
    	);
    }

    • Marked as answer by Dismantled Saturday, June 21, 2014 3:05 PM
    Saturday, June 21, 2014 3:05 PM

All replies

  • I think what my problem is in a different types of object - which i've got and which i trying to put.

    In result[0] i've got array of "Object" type.

    But the "From" field required "LookupControlItem" object array. "LookupControlItem" puts fine.

    Maybe there is something method to convert results[0] to "LookupControlItem"?

    Or another workaround to get lookup item except SDK.JQuery.retrieveMultipleRecords?

    Please help!

    Saturday, June 21, 2014 10:35 AM
  • function CorrectMail() {
    	SDK.JQuery.retrieveMultipleRecords(
    		"Queue",
    		"$select=QueueId,Name&$filter=Name eq 'MyQueue'",
    		function (results) {
    			
    			// Get some LookupControlItem to use as template
    			var tmpObject = Xrm.Page.getAttribute("ownerid").getValue();
    			
    			// Insert required data
    			tmpObject[0].ambiguousRecordsXml = undefined;
    			tmpObject[0].callback = "openlui(new Sys.UI.DomEvent(event))";
    			tmpObject[0].category = undefined;
    			tmpObject[0].data = undefined;
    			tmpObject[0].displayClass = "ms-crm-Lookup-Item";
    			tmpObject[0].entityType = "queue";
    			tmpObject[0].id = "{" + results[0].QueueId + "}";
    			tmpObject[0].name = results[0].Name;
    			tmpObject[0].onclick = undefined;
    			tmpObject[0].selected = undefined;
    			tmpObject[0].type = "2020";
    			tmpObject[0].typename = "queue";
    
    			// Put the Queue into the form
    			Xrm.Page.getAttribute("from").setValue([tmpObject[0]]);
    
    		},
    		function (error) { alert(error) },
    		function () {}
    	);
    }

    • Marked as answer by Dismantled Saturday, June 21, 2014 3:05 PM
    Saturday, June 21, 2014 3:05 PM