locked
Set lead owner RRS feed

  • Question

  • Hi,

    I'm creating a lead like this

     

    Dim lead As New lead()
            lead.subject = "Confirm Quote Request from website"
            lead.firstname = txtFullName.Text
            lead.companyname = txtCompanyName.Text
            lead.telephone1 = txtTelephone.Text
            lead.emailaddress1 = txtEmail.Text
            lead.description = txtDescription.Text
            service.Create(lead)

    This works fine - but how can I set the owner of the lead.

    There is a property called OwnerId of type Owner, but how do I set this to a specific user

    Thanks

    Friday, May 14, 2010 12:26 PM

Answers

  • hi

    use  AssignRequest  Message. see here

    SecurityPrincipal assignee = new SecurityPrincipal();
    assignee.Type = SecurityPrincipalType.User;

    // PrincipalId is some known Guid belonging to the user or team that will own this record.
    assignee.PrincipalId = new Guid("326A0053-71CB-465E-9BEB-633E2E0851A9");

    // Create the target object for the request.
    TargetOwnedAccount target = new TargetOwnedAccount();

    // Set the properties of the target object.
    // EntityId is some known Guid belonging to the account that is being assigned to the user.
    target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

    // Create the request object.
    AssignRequest assign = new AssignRequest();

    // Set the properties of the request object.
    assign.Assignee = assignee;
    assign.Target = target;
         
    // Execute the request.
    AssignResponse assignResponse = (AssignResponse)service.Execute(assign);

    http://msdn.microsoft.com/en-us/library/bb959372.aspx

     


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Friday, May 14, 2010 1:06 PM
  • Something like

    WhoAmIRequest whoami = new WhoAmIRequest();
    WhoAmIResponse response = (WhoAmIResponse)service.Execute(whoami);
    Guid id = response.UserId;


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Friday, May 14, 2010 2:43 PM
    Moderator

All replies

  • hi

    use  AssignRequest  Message. see here

    SecurityPrincipal assignee = new SecurityPrincipal();
    assignee.Type = SecurityPrincipalType.User;

    // PrincipalId is some known Guid belonging to the user or team that will own this record.
    assignee.PrincipalId = new Guid("326A0053-71CB-465E-9BEB-633E2E0851A9");

    // Create the target object for the request.
    TargetOwnedAccount target = new TargetOwnedAccount();

    // Set the properties of the target object.
    // EntityId is some known Guid belonging to the account that is being assigned to the user.
    target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

    // Create the request object.
    AssignRequest assign = new AssignRequest();

    // Set the properties of the request object.
    assign.Assignee = assignee;
    assign.Target = target;
         
    // Execute the request.
    AssignResponse assignResponse = (AssignResponse)service.Execute(assign);

    http://msdn.microsoft.com/en-us/library/bb959372.aspx

     


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Friday, May 14, 2010 1:06 PM
  • following is code for the same

    Dim result as New Owner()

    result.type = EntityName.systemuser.ToString()

    result.value = <<Guid of user>>

    lead.ownerid = result;

    • Proposed as answer by Aarch Monday, May 17, 2010 5:58 AM
    Friday, May 14, 2010 1:09 PM
  • following is code for the same

    Dim result as New Owner()

    result.type = EntityName.systemuser.ToString()

    result.value = <<Guid of user>>

    lead.ownerid = result;


    Thanks for this - where do I find the GUID of the user?

    Friday, May 14, 2010 2:35 PM
  • Hi,

    you can get GUID of the systemuser by just opening that particular user's record and press F11 on addressbar you can see GUID.


    Mahain
    Friday, May 14, 2010 2:42 PM
    Moderator
  • Something like

    WhoAmIRequest whoami = new WhoAmIRequest();
    WhoAmIResponse response = (WhoAmIResponse)service.Execute(whoami);
    Guid id = response.UserId;


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Friday, May 14, 2010 2:43 PM
    Moderator