locked
Retrieve AccountID from account entity RRS feed

  • Question

  • Hi,

    I want to update the 'account' entity through the 'Organization.svc'  webservice.

    I guess I will need the GUID object of this specific record.  How can I get hold of it?

    Regards,

    Anthonie


    Monday, November 28, 2011 3:28 PM

Answers

  • I think I have it,

     

    I've created a multiple selection query with my unique field:

     

      QueryExpression myAccountQuery =  new QueryExpression
                {
                    EntityName = "account",
                    ColumnSet = new ColumnSet("accountid"),
                    Criteria = new FilterExpression
                    {
                        Conditions = 
                        {
                            new ConditionExpression
                            {
                              AttributeName  =  "new_customernumber",
                              Operator = ConditionOperator.Equal,
                              Values = {_sMyId}
                            }
                        }
                    }
                };
                var myAccount = service.RetrieveMultiple(myAccountQuery);
    from the myAccount I can get the GUID. 
    Please let me know if there is a better method.
    Monday, November 28, 2011 4:02 PM
  • That's one way of retrieving the account and is a good method to use. The other options for querying data include FetchXML, FilteredViews, LINQ and QueryByAttribute! So there are quite a lot of options, but all will do exactly the same thing in your case so stick with QueryExpression!

    Kirsten

    Monday, November 28, 2011 4:06 PM

All replies

  • Hi Anthonie,

    There are a number of ways of retrieving the account id. It would be helpful to know your scenario, are you working in javascript or c#? Is it a plugin or workflow or client app?

    [Aside: You can always get specific account ids from the url for the account form for one offs or testing. Just click 'copy a link' on the account form, paste into notepad and use the value of the id querystring (removing the encoded {} %7b and %7d from the beginning and end). But this probably isn't quite what you are looking for :-)]

    Kind regards

    Kirsten

    Monday, November 28, 2011 3:48 PM
  • Hi Kirsen,

     

    I'm using c# in a custom application.  I'm writting an update utility that update account details from a csv document.  So the only thing I have to compare with is the company number and company name. That should be unique.

     

    Regards,

    Anthonie

    Monday, November 28, 2011 3:55 PM
  • I think I have it,

     

    I've created a multiple selection query with my unique field:

     

      QueryExpression myAccountQuery =  new QueryExpression
                {
                    EntityName = "account",
                    ColumnSet = new ColumnSet("accountid"),
                    Criteria = new FilterExpression
                    {
                        Conditions = 
                        {
                            new ConditionExpression
                            {
                              AttributeName  =  "new_customernumber",
                              Operator = ConditionOperator.Equal,
                              Values = {_sMyId}
                            }
                        }
                    }
                };
                var myAccount = service.RetrieveMultiple(myAccountQuery);
    from the myAccount I can get the GUID. 
    Please let me know if there is a better method.
    Monday, November 28, 2011 4:02 PM
  • That's one way of retrieving the account and is a good method to use. The other options for querying data include FetchXML, FilteredViews, LINQ and QueryByAttribute! So there are quite a lot of options, but all will do exactly the same thing in your case so stick with QueryExpression!

    Kirsten

    Monday, November 28, 2011 4:06 PM
  • Thx for your help!!
    Monday, November 28, 2011 4:10 PM