Answered by:
Change a record's owner with javascript

Question
-
Hello,
I want to change owner a custom entity's record with javascript.
I tried to write a JS code, but it doesn't work.
What is the wrong this code. Or could you help me please?Regards
Yildirayvar userid = "86B2EBFA-BA6A-DD11-84D4-0016357F5F41"; // This is new Owner ID
var recordid = "EE11FC83-7C33-E011-817F-0016357F5F41"; // This is the record ID which will be updated.... I don't know is it true?
var target = "TargetOwnedDynamic"; // This is for custom entityvar xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
header +
" <soap:Body>" +
" <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <Request xsi:type=\"AssignRequest\">" +
" <Target xsi:type=\""+ target +"\">" +
" <EntityName>new_entityname</EntityName>"+
" <EntityId>"+ recordid +"</EntityId>" +
" </Target>" +
" <Assignee>" +
" <PrincipalId xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">"+ userid +"</PrincipalId>" +
" <Type xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">User</Type>" +
" </Assignee>" +
" </Request>" +
" </Execute>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
MS CRM- Moved by Kimberlee Johnson Tuesday, February 8, 2011 3:26 PM Jscript question (From:Dynamics CRM)
Tuesday, February 8, 2011 3:03 PM
Answers
-
here is a related post that will help you
http://social.microsoft.com/Forums/en/crmdevelopment/thread/a804bbe9-512c-44a9-b5b1-90f16b44a8b2
MSCRM Bing'd - http://bingsoft.wordpress.com Check out the CRM 4 to CRM 2011 JavaScript Converter Tool CRM Forum Guidance on how to Help Us Help You - Proposed as answer by RhettClintonMVP, Moderator Tuesday, February 8, 2011 3:41 PM
- Marked as answer by Jim Glass Jr Tuesday, February 8, 2011 10:28 PM
Tuesday, February 8, 2011 3:40 PMModerator
All replies
-
here is a related post that will help you
http://social.microsoft.com/Forums/en/crmdevelopment/thread/a804bbe9-512c-44a9-b5b1-90f16b44a8b2
MSCRM Bing'd - http://bingsoft.wordpress.com Check out the CRM 4 to CRM 2011 JavaScript Converter Tool CRM Forum Guidance on how to Help Us Help You - Proposed as answer by RhettClintonMVP, Moderator Tuesday, February 8, 2011 3:41 PM
- Marked as answer by Jim Glass Jr Tuesday, February 8, 2011 10:28 PM
Tuesday, February 8, 2011 3:40 PMModerator -
You can also use:-
http://danielcai.blogspot.com/2010/07/crm-web-service-toolkit-for-javascript.html
Regards FaisalTuesday, February 8, 2011 5:56 PM -
Can you please mention the exact scenario ?Wednesday, February 9, 2011 6:15 AM
-
I have a custom entity which name is new_entityname. it contains four field which are new_userid, new_date, new_trigger and new_field1.
when I change new_trigger field value on form, it is creating a task record. (I used Javascript create method). I can receive new cretaed Task GUID. It is OK.
On next step, I want to assign the created task to new_userid.
MS CRMWednesday, February 9, 2011 9:04 AM