Hi ,
I would like to set the value to a lookup(custom fields) in the account entity via WCF Service but am getting an error as "Unrecognised Guid format"
string UserId = objCrmSdk.GetUserId(objAccount.ModifiedBy);
if (UserId != null)
{
entity["new_assigned to"] = new EntityReference("systemuser", new Guid(UserId));
entity["new_assignedfrom"] = new EntityReference("systemuser", new Guid(UserId));
}
GetUserIdFunction:
public string GetUserId(string Modifiedby)
{
string SystemUserId = string.Empty;
//string UserId;
try
{
if (string.IsNullOrEmpty(Modifiedby))
{
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(Utility.OrgURL, Utility.DiscoveryURL, null, null))
{
IOrganizationService service = (IOrganizationService)serviceProxy;
string GetSystemUserId = string.Format(@"
<fetch distinct='false' mapping='logical'>
<entity name='systemuser'>
<attribute name='systemuserid'/>
<filter>
<condition attribute='fullname' operator='eq' value='{0}'/>
</filter>
</entity >
</fetch>", Modifiedby);
EntityCollection UserCollection = service.RetrieveMultiple(new FetchExpression(GetSystemUserId));
if (UserCollection.Entities.Count > 0)
{
Guid UserId = UserCollection.Entities[0].Id;
SystemUserId = Utility.ToString(UserId);
}
}
}
}
return SystemUserId;
}
Thanks in advance!