Using sdk to find out if an Account already exists

Hi,
Want to use sdk to see if an Account already exists , all i have is
its name.
I've looked at Retrieve method but it requires the Guid.

Any equivalent call to Retrieve that just takes name? Or a way to get
the Guid from the name?
Sample code would be great if available.

Thanks for all help.

John

0
John
3/8/2007 1:17:58 PM
crm 35858 articles. 1 followers. Follow

2 Replies
994 Views

Similar Articles

[PageSpeed] 45

Hi John,

The method you are looking for is RetrieveMultiple as only the guid
search gives the certainty to retrieve only one record.
All explanations are in the sdk but as the sdk sample is nearly the
exact code you want, here it is :

// Set up the CRM Service.
CrmService service =3D new CrmService();
service.Credentials =3D System.Net.CredentialCache.DefaultCredentials;

// Create the column set that indicates the fields to be retrieved.
ColumnSet cols =3D new ColumnSet();

// Sets the properties of the column set.
cols.Attributes =3D new string [] {"name", "accountid"};

// Create the condition expression.
ConditionExpression condition =3D new ConditionExpression();

// Set the condition for the retrieval to be when the account name is
"alpha"
condition.AttributeName =3D "name";
condition.Operator =3D ConditionOperator.Like;
condition.Values =3D new string [] {"alpha"};

// Create the filter expression.
FilterExpression filter =3D new FilterExpression();

// Set the properties of the filter.
filter.FilterOperator =3D LogicalOperator.And;
filter.Conditions =3D new ConditionExpression[] {condition};

// Create the QueryExpression object.
QueryExpression query =3D new QueryExpression();

// Set the properies of the QueryExpression object.
query.EntityName =3D EntityName.account.ToString();
query.ColumnSet =3D cols;
query.Criteria =3D filter;

// Create the request object.
RetrieveMultipleRequest retrieve =3D new RetrieveMultipleRequest();

Hope this could be of some help.
Have a nice day,
St=E9phane Dorrekens
Traviata




0
Stephane
3/8/2007 1:26:10 PM
On Mar 8, 1:26 pm, "Stephane Dorrekens"
<stephane.dorrek...@traviata.be> wrote:
> Hi John,
>
> The method you are looking for is RetrieveMultiple as only the guid
> search gives the certainty to retrieve only one record.
> All explanations are in the sdk but as the sdk sample is nearly the
> exact code you want, here it is :
>
> // Set up the CRM Service.
> CrmService service =3D new CrmService();
> service.Credentials =3D System.Net.CredentialCache.DefaultCredentials;
>
> // Create the column set that indicates the fields to be retrieved.
> ColumnSet cols =3D new ColumnSet();
>
> // Sets the properties of the column set.
> cols.Attributes =3D new string [] {"name", "accountid"};
>
> // Create the condition expression.
> ConditionExpression condition =3D new ConditionExpression();
>
> // Set the condition for the retrieval to be when the account name is
> "alpha"
> condition.AttributeName =3D "name";
> condition.Operator =3D ConditionOperator.Like;
> condition.Values =3D new string [] {"alpha"};
>
> // Create the filter expression.
> FilterExpression filter =3D new FilterExpression();
>
> // Set the properties of the filter.
> filter.FilterOperator =3D LogicalOperator.And;
> filter.Conditions =3D new ConditionExpression[] {condition};
>
> // Create the QueryExpression object.
> QueryExpression query =3D new QueryExpression();
>
> // Set the properies of the QueryExpression object.
> query.EntityName =3D EntityName.account.ToString();
> query.ColumnSet =3D cols;
> query.Criteria =3D filter;
>
> // Create the request object.
> RetrieveMultipleRequest retrieve =3D new RetrieveMultipleRequest();
>
> Hope this could be of some help.
> Have a nice day,
> St=E9phane Dorrekens
> Traviata

Worked a treat , thanks very much

0
John
3/8/2007 2:57:46 PM
Reply:

Similar Artilces:

Watch Accounts
I've set up a watch account to use as a model for an investing strategy I'd like to try. In doing so, I want to be able to track theoretical purchases and sales of individual stocks. I want to track sales and realized gains on my Account Summary window, so I've customized my view to do that. After entering a purchase, the stock shows up just fine on my account summary, but after I sell all shares, it no longer shows up so I'm not able to track realized gains. How can I get Money to continue to display the stocks I no longer "own" in my watch account? a w...

Business Portal Error-SQL server does not exist or access denied
Hi, We are running business portal 4.0 for one of our customer. It was running correctly, however, they have changed the SQL server port (previously it was set as default 1433). After that the business portal becomes very slow and while creating a new request (purchase requisition) if we open the item pop up; it is showing exception "SQL Server does not exist or access denied...." Can any body tell me how can I provide the new port number to business portal connection to the database. Thanks and Regards, Waliullah, Thanks for using the newsgroups. I have a...

Send to certain person using specific email account
I send an email to a certain receipient but don't want to use the default email account. Is it possible that when I send to them (plain text) , that it will choose the other account I want to use to send it? Please advise how I set this up. Thanks. I do not believe that this can be achieved automatically through standard use of Outlook as you need to manually specify the name of the account to send from if different than the default. However, it would be possible using the Outlook object model. An Addin would need to be developed that monitored each mail item prior to sending. If the d...

Using mouse wheel in VB editor
Just tried using the mouse wheel to scroll within visual basic editor in excel but it wont let me. How can I turn this feature on. I am using Excel 2003. Thanks in advance. This is a known problem with the latest MS mouse drivers. You can either install version 4 of the drivers (current version is 5), or use FreeWheel, and freeware program at http://www.geocities.com/SiliconValley/2060/freewheel.html . -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "fullers" <fullers@discussions.microsoft.com> wrote in message ne...

Resolving Email Address to existing contact problem
Has anyone else come across this issue in MSCRM3.0? - when you attempt to resolve an email address to an existing contact in CRM (that does not currently have an email address stored in their details) the contact resolves OK but does not update the email address in the contacts details. Is this by design, or have I found a bug? ...

Converting Opportunity to Account
How do I convert an Opportunity to a Account? Thanks This is not possible, opportunities are opportunities for existing accounts/contacts. This is why when you convert a Lead to an Opportunity you must select the potential customer also. Regards Dan "circulent" wrote: > How do I convert an Opportunity to a Account? Thanks how would I select a potential customer? does this mean I have to create an account for them as well? it wouldnt make sense since they may not ending up being an account. thoughts? "Dan Quinton" wrote: > This is not possible, opportunities...

OLK 2k7
Outlook is behaving strangly with the "through the selected account" option. Each time I restart Outlook the rule fails. When I go in to check on the rules I get told that the rule is "invalid". and the "SELECTED" account is no longer selected. Each time the criteria the account needs to be selected by changes. For example with the following data Account Name Email Account mailserver.domain1.com user@domain1.com mailserver.domain2.com user@domain2.com One time I go in and it's asking me to select the account ...

Setting up a new e-mail account
I'm trying to set up my yahoo account so that I receive my e-mail messages in my Outlook Inbox. I went to Accounts, and servers, and put in mail.yahoo.com for incoming mail (POP3) and smtp.yahoo.com for outgoing mail (smtp). When I click on the send/receive button I get an error message. Dave <anonymous@discussions.microsoft.com> wrote: > I'm trying to set up my yahoo account so that I receive > my e-mail messages in my Outlook Inbox. I went to > Accounts, and servers, and put in mail.yahoo.com for > incoming mail (POP3) and smtp.yahoo.com for outgoing mail &...

Use exchange from a trusted domain
Hi folks, I have domain a and domain b. Domain a is all set upp with exchange etc. Domain b was bought, and they don't have exchange. I have trust between the domains and file sharing and authentication are ok. What we want to do is, make users on domain b and let them use the exchange (on a seperate storage) on domain a. The users on domain b must logon to domain b, but need to have mailbox on domain a. Domain a are running on win2003 and exchange 2003. Domain are running on win2003 with forest and domain ready for exchange. Any advices? thanks in advance, - Bjarni Hi, Thi...

Using Access 2003 on client to see Sharepoint 2007
Testing a Sharepoint environment and I can easily manipulate and run the database from Access 2007, but when I try to use Access 2003 it wants me to save the database to a location. The Access 2003 has the compatiblity pack, but it seems to not work when I download it. So the question is using Sharepoint 2007 and posting the Access 2007 format to it, can a user go to the sharepoint site and use a 2003 Access database that has the compatibility pack and open without having to download it? -- Message posted via http://www.accessmonster.com Send check for $500.00 to: David A Jenn...

Archiving Projects in Project Accounting
Has anyone found a way to archive closed projects? Thanks. ...

Associating Multiple Existing Contacts to an Account, Until CRM 2.x
I have racked my pea-sized brain for endless days for a way to associate multiple existing contacts (or accounts) to an account. My client has accounts that have many contacts (or accounts) involved at different stages of acquiring a new account. The logical method would be to add a custom attribute with lookup functionality into the existing CRM contact or account objects but this is not possible with CRM 1.x. The resulting UI would allow an end user to associate different contacts (or accounts) to an account. Example: Account: ABC - AccountPhysician: (existing account or con...

Money 2000 Account Balance Changed Inexplicably
Opening Money 2000, which I've used without problem since late 1999, I noticed that my checking account balance was overstated by almost $2000! I went to the register to see if there was a false transaction entered and it appears that this balance change goes back years with no obvious single entry being the culprit. When I run the "balance this account" function, it shows that the closing balance from my last statement, which was correct and rectified, is now also wrong and reflects the higher balance. What do I do now? The only thing that I can think of is to restore...

I want to add a mail account without setting a SMTP server. Is it possible?
I want to add a second mail account that is outside my company. Since the company firewall does not allow us to connect to SMTP-servers I want to add this account without setting the SMTP propertiy. I cannot specify the company server as it is an Exchange server and the outside one an IMAP one. Currently I have specified the outside SMTP server since outook does not allow me to add an account wihtout setting this. I keep getting annoying error messages as my computer can't connect to the outside SMTP. Any one know a way around this? cheers, mortb The company server has SMTP enabled, u...

How Use ShellExecute with a CMemFile
Hello, I need to store files of various types (such as .doc, .xls, .jpg, .pdf, ..wmv, ...) in a database. Upon retrieval of such a file I have the file as data in memory in a CMemFile. I need to then "display" the file in the aproriate application. If I were to write the CMemFile to disk and create an actual file I could then, of course, use ShellExecute() to launch , say Word to display a .doc file. However, I would much prefer to avoid the overhead of writing the data to an actual file and then dealing with having to detect when the User is done and cleaning up the file I had ...

Can i use conditional formating on a cell when it contains a formula?
I am trying a "conditional formatting" on a cell that contains formula, but it didn't work. "If cell value is equal to 0 then font - white" This doesn't work, stays always. If i use this condition on a cell without formula it works just fine. Thank -- si ----------------------------------------------------------------------- sit's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=262 View this thread: http://www.excelforum.com/showthread.php?threadid=26784 Hi are you sure your formula returns an exact zero?. Could you post the formul...

Using INDIRECT within functions
I learned a bit from JLathman in a previous post but tried to use the same methodology with this formula (also learned from this Group to get the last entered value in a column) without much luck. The original formula was this with 2009 sheet being static: =LOOKUP(2,1/('2009'!H3:H65536<>""),'2009'!H3:H65536) Trying to make it dynamic I tried the following without success: =LOOKUP(INDIRECT("2,1/(" & O1 & "!$H$3:$H$65536<>"")," & O1 & "!$H$3:$H$65536)")) Did I miss something or are...

Outllok 2003 reply with wrong account
Howdy - I have Outlook 2003. For some reason my new pc has started doing the same thing as my previous one. I have 5 email accounts. When a person sends me an email to my default account and I reply, it comes from another account. In theory (and it did until the last couple of days) it should come from the account I received the email in.... I change the smtp settings on the accounts as I travel a lot, but other than that I haven't changed anything that I know of to cause this - anyone had the same problem, or better yet - know how to fixt it???!!! Thanks in advance Ron ...

unable to grant existing user access to TEST company
Set up test company using live company data; ran the script referenced in CustomerSource article ID#871973; can grant and remove user access in all other companies; ran grantsql 9.2; the dexsql log shows the user already has access probably because of using the other company data for the test; I can set up a new user and grant them access, existing users who already have access can view the company...but, I cannot figure out how to grant access to the TEST company to an existing user. The error popup reads "The user could not be added to one or more databases." Dynamics 9.0,...

How to use count for calls per hour
I am trying to create a pivot table and chart that will show me the # of calls per hour by day for a range of dates Aug 1 - Sept 19. My data looks like this where each line is the date and time of the call: How do I get a count of the # of the calls per hour by day? 8/1/08 12:48 AM 8/1/08 1:53 AM 8/1/08 2:36 AM 8/1/08 3:24 AM 8/1/08 3:37 AM 8/1/08 4:04 AM 8/1/08 4:44 AM 8/1/08 4:55 AM 8/1/08 4:58 AM 8/1/08 7:02 AM 8/1/08 7:28 AM 8/1/08 7:43 AM 8/1/08 7:47 AM 8/1/08 7:56 AM 8/1/08 7:58 AM 8/1/08 8:13 AM 8/1/08 8:33 AM 8/1/08 9:07 AM 8/1/08 10:28 AM 8/1/08 10:38 AM 8/1/08 10:44 AM 8/1/08 ...

Re-enabled user account cannot log in
In trying to troubleshoot and issue in CRM where I had multiple user accounts for a single ADUC user, I tried disabling and re-enabling a user's account. But even after re-enabling the account the user cannot log in now. The error message says that it is disallowed when he tries to browse to the CRM server. Please help, I need to get this user account working again asap. Joel ...

How export all mailbox-enabled users from the GAL using Outlook?
Hello, We have a user which, for administrative reasons, needs to export all mailbox-enabled users in the GAL now and then. They just need all the names. Is there a straightforward way for them to do that? We don't want to give them any special permissions and want to avoid server scripting. Ideally, they should be able to export it to a CSV file or any text file. Thanks, - Alan. Alan wrote: > We have a user which, for administrative reasons, needs to export all > mailbox-enabled users in the GAL now and then. They just need all the > names. Is there a straightforward way fo...

find instance of IE for server socket in activex component
Hi I have an activex component that has a server socket (using casyncsocket class) ..The problem is that when I have multiple instances of the IE open only the first instance (created first) recieves the messages the rest do not recieve the message. Is there a way to solve this problem .(i want the server send the reply to that instance of ie that sent the message) .Do I need to pass something like a pointer of hte javascript object .If so how Thanks When you say "server socket", that suggests a socket that does a Listen followed by an Accept. Otherwise it is a client socke...

find data and autopaste when found
Hi, Can someone help me how to do this : For checken the backorders of our customers we can extract a list fro our SAP system. this list is always different and shows us ever product per customer in Back order. ex. Customer A has product 1 en in backorder. This gives 2 lines in the xls file. can excel put th name of the customer on a form and it's backorders automatically. Ca it create for each customer showing in the list a new form? thanks koenraa -- Message posted from http://www.ExcelForum.com ...

SQL 2008 running on a VM using all allocated memory
Hi, I've got a sql2008 server running on a VM. There's 9GB of physical RAM, which 7GB have been allocated to SQL Server. But when i look at task manager, i see that the SQL server is actually using all 7GB, which is pegging the memory usage of the overal box at above 90% used. We're mostly a sql2005 shop, and none of those servers are doing this. I have sql2005 running on VM's, someone actual servers as a named or default instance, and some even clustered. None of them have this problem. Is this a normal thing with sql2008 only? Any insight would be greatly appre...