Answered by:
Javascript Soap Create does not change owner

Question
-
I have a custom entity that I am "cloning". I use a soap message and create the xml from the screen fields. I use whoamI to get the current system user. I add <ownerid> + userid + </ownerid> to the soap message. The create works, but the ownerid is not changed. What am I missing?Monday, July 6, 2009 5:09 PM
Answers
-
I havent tested yet, but the request would be something like this:
<?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"> <soap:Header> <CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices"> <AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">2</AuthenticationType> <OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">solus-vivo</OrganizationName> <CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId> </CrmAuthenticationToken> </soap:Header> <soap:Body> <Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices"> <Request xsi:type="AssignRequest"> <Target xsi:type="TargetOwnedAccount"> <EntityId>382f603c-1667-de11-8ed0-00155d2ab209</EntityId> </Target> <Assignee> <PrincipalId xmlns="http://schemas.microsoft.com/crm/2006/CoreTypes">3e0b0ae5-1718-de11-832e-00155d2ab209</PrincipalId> <Type xmlns="http://schemas.microsoft.com/crm/2006/CoreTypes">User</Type> </Assignee> </Request> </Execute> </soap:Body>
The PrincipalId is the id of the new owner, and the EntityId is the id of the custom entity.
Hope it helps!!!
Fred.- Proposed as answer by Amol Gholap [Neudesic] Monday, July 6, 2009 6:37 PM
- Marked as answer by KCJodi Monday, July 6, 2009 9:46 PM
Monday, July 6, 2009 6:31 PM -
I forgot, your using a custom entity, try changing the target, like this:
<Target xsi:type="TargetOwnedDynamic"> <EntityName>account</EntityName> <EntityId>382f603c-1667-de11-8ed0-00155d2ab209</EntityId> </Target>
And change the EntityName to your custom entity.
Gook Luck- Marked as answer by KCJodi Monday, July 6, 2009 9:47 PM
Monday, July 6, 2009 9:17 PM
All replies
-
You cannot just set the field of the owner.
You have to use the AssignRequest class to do it.
Good Luck!!!
Monday, July 6, 2009 5:44 PM -
Thanks Frederico,
Do you have an example you would share. I can seem to find a soap message.Monday, July 6, 2009 6:22 PM -
Here is code of C#. You can use stunnware tools to create equivalent soap message.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
assignee.PrincipalId = Userid; // took the Current User from your code
TargetOwnedIncident target = new TargetOwnedIncident();
target.EntityId = new Guid(arrGuids[i].ToString());
AssignRequest assign = new AssignRequest();
assign.Assignee = assignee;
assign.Target = target;
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);
Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholapMonday, July 6, 2009 6:28 PM -
I havent tested yet, but the request would be something like this:
<?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"> <soap:Header> <CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices"> <AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">2</AuthenticationType> <OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">solus-vivo</OrganizationName> <CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId> </CrmAuthenticationToken> </soap:Header> <soap:Body> <Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices"> <Request xsi:type="AssignRequest"> <Target xsi:type="TargetOwnedAccount"> <EntityId>382f603c-1667-de11-8ed0-00155d2ab209</EntityId> </Target> <Assignee> <PrincipalId xmlns="http://schemas.microsoft.com/crm/2006/CoreTypes">3e0b0ae5-1718-de11-832e-00155d2ab209</PrincipalId> <Type xmlns="http://schemas.microsoft.com/crm/2006/CoreTypes">User</Type> </Assignee> </Request> </Execute> </soap:Body>
The PrincipalId is the id of the new owner, and the EntityId is the id of the custom entity.
Hope it helps!!!
Fred.- Proposed as answer by Amol Gholap [Neudesic] Monday, July 6, 2009 6:37 PM
- Marked as answer by KCJodi Monday, July 6, 2009 9:46 PM
Monday, July 6, 2009 6:31 PM -
Hey Fred,
I think I am close to getting the soap message to work. It appears to be returning a system warning on "entityName".
Any ideas?Monday, July 6, 2009 9:07 PM -
I forgot, your using a custom entity, try changing the target, like this:
<Target xsi:type="TargetOwnedDynamic"> <EntityName>account</EntityName> <EntityId>382f603c-1667-de11-8ed0-00155d2ab209</EntityId> </Target>
And change the EntityName to your custom entity.
Gook Luck- Marked as answer by KCJodi Monday, July 6, 2009 9:47 PM
Monday, July 6, 2009 9:17 PM -
Yep, that took care of it. Thanks for your help.
Next time I will be doing my coding in C#.
JScript is just to hard to debug.Monday, July 6, 2009 9:46 PM -
Well, it seems my solution is partially working. The assign request is changing the owner as long as I am system administrator. when I run the browser in a different security role, sales rep, I get error 0x80048306 which seems to say I do not have enough priviledge to access the CRM object or to perform the requested operation. I went to the role ane up the priviledge to organization for append, appendto and assign.
Have you run into this before?Tuesday, July 7, 2009 3:37 PM -
Humm... now you got me... it should be the assign privilege...
You're gonna have to play around with the permissions to find witch is the one..
CRM Roles are tricky..
Good Luck...Tuesday, July 7, 2009 5:32 PM -
I ended up giving full organizational permission to the role on my custom entity on create, append, appendto and assign.Tuesday, July 7, 2009 7:23 PM
-
Thanks very much for you answer. I have looked for the stunnware tool and cannot locate the download.
Can you assist?Friday, July 10, 2009 9:33 PM -
The download link is in the upper left corner, you can quick find "download", and you will find it! =D
http://www.stunnware.com/crm2/topic.aspx?id=JSWebService2Friday, July 10, 2009 10:27 PM