Web Service Query Question

I have 3 conditions in my webservice that i use to retrieve contact records 
from crm. The first two conditions ( Firstaname and Lastname) are mandatory 
and the last one (date of birth) is not. I want to exclude the last condition 
if it is empty. Here is my code which doesnt work. At the end i have an if 
statement which I thought it will do what i want. Please help

               // Return distinct values
                query.Distinct = true;

                // Setup the query for the contact entity
                query.EntityName = "contact";

                // Specify the columns to retrieve
                ColumnSet columns = new ColumnSet();
                columns.Attributes = new String[] {"contactid",

                query.ColumnSet = columns;

                query.Criteria = new FilterExpression();
                query.Criteria.FilterOperator = LogicalOperator.Or;

                // Create the lastname condition
                ConditionExpression condition1 = new ConditionExpression();
                condition1.AttributeName = "lastname";
                condition1.Operator = ConditionOperator.Like;
                condition1.Values = new Object[] {Lastname};

                // Create the firstname condition
                ConditionExpression condition2 = new ConditionExpression();
                condition2.AttributeName = "firstname";
                condition2.Operator = ConditionOperator.Like;
                condition2.Values = new Object[] {Firstname};

                // Create the birthdate condition
                ConditionExpression condition3 = new ConditionExpression();
                condition3.AttributeName = "birthdate";
                condition3.Operator = ConditionOperator.Equal;
                condition3.Values = new Object[] { convDate(DoB) };
                //filter1 = new FilterExpression();
                //filter1.FilterOperator = LogicalOperator.Or;

                //filter2 = new FilterExpression();
                //filter2.FilterOperator = LogicalOperator.Or;

                //query.Criteria.Filters = new FilterExpression[] {filter1, 

                OrderExpression order1 = new OrderExpression();
                order1.AttributeName = "fullname";
                order1.OrderType = OrderType.Ascending;

                query.Orders = new OrderExpression[] {order1};

                if (condition3.Values == null )
                    query.Criteria.Conditions = new ConditionExpression[] { 
condition1, condition2};
                query.Criteria.Conditions = new ConditionExpression[] { 
condition1, condition2, condition3};

Many Thanks.

Phumulani (20)
4/7/2009 2:06:03 PM
crm 35858 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 23

Conditions have to be set on the filter, which is something you don't
seem to be doing:


filter.Conditions = New CRM.ConditionExpression() {condition1,
condition2, condition3}

anedza (69)
4/7/2009 8:47:24 PM
Hi Andy,

Thanks for the quick response. I'm new to c# sharp can you please provide 
the example using my three conditions above. 

Thanks in advance.

"Andy" wrote:

> Conditions have to be set on the filter, which is something you don't
> seem to be doing:
> ie
> filter.Conditions = New CRM.ConditionExpression() {condition1,
> condition2, condition3}
Phumulani (20)
4/8/2009 7:21:01 AM

Similar Artilces:

Anyway to start the "Messenger" service only when connected to AD?
I use quite a lot of "send net" to broadcast important messages to the whole domain. But the "messenger" service has to be started in order to receive messages. However, more than half of the computers are portables that the owners could bring back home. And when they're home, they're connected to Internet with every mean available to them. And it's better that the Messenger service is stopped to avoid spam messages from Internet or other virus. So, is there a way to start this service when these portables are connected to the AD. And when they'...

Query to find when a total is hit
We are trying to get some statistics on our Inventory people to see if they are issuing material to work orders on time. My work order table has a field that shows the last transaction date of the order, but if Inventory issue all the material then has to issue more because of scrap later they get dinged as being late. We have a Transaction History table that shows every issue however I don't know a good way to find out when the total number of needed parts was reached. For Example I am creating a shop order that needs 3 parts, 50 of each: ShopOrder PartNeeded D...

Question about Outlook 2003 Disk
I just bought one of the stand alone office products, Microsoft Outlook 2003. On the face of the disk it reads, "Microsoft Office Outlook Standard 2003" Can anyone tell me what the standard part of the title means? I assumed there was only one version of outlook 2003, I don't recall seeing standard, plus or premium versions of the program on Microsofts website. I bought the software from softwareoutlet.com, who had very high ratings so I wen't with them because they seemed like they could be trusted. Did I get what I was suppose to get or what? Also the color of the dis...

Web Access
How does one go about setting up outlook web access? If you have Exchange 2000 Server, it should be configured "out of the box". Exchange 5.5 requires you to install it separately, but it's pretty easy to configure. Which version of Exchange are you running, Adam? -- Regards, Chris Burnham Microsoft Exchange Support This posting is provided "AS IS" with no warranties, and confers no rights. ------------------- "Adam" <akinney@ceesi.com> wrote in message news:02c201c347d3$e7a3d050$a101280a@phx.gbl... > How does one go about setting up outlook web ...

Query Help re subtotals and totals
Hi,I have a very rudimetary database for managing customer problems.This contains a simple totals query which groups the records by the field customername and counts the field problemcategory. This gives me the total number of problems per customer.How can I modify it so I have an additional field detailing what each respective count represents as a percentage of the total number of problems. I've been trying to figure out an expression which would do this but have been unsuccesful.Any help would be extremely appreciated,Thanks,Jay...

Query help. 02-05-10
Given 2 tables below and how can I get the results showing below. The rules are described below. Thank you for your help in advance. IF OBJECT_ID('Tempdb.dbo.#Client', 'u') IS NOT NULL DROP TABLE #Client GO CREATE TABLE #Client ( ClientId INT NULL, ClientName VARCHAR(20) NULL ) GO IF OBJECT_ID('Tempdb.dbo.#Account', 'u') IS NOT NULL DROP TABLE #Account GO CREATE TABLE #Account ( ClientId INT NULL, AccountId INT NULL, AccountValue INT NULL, Insertdt DATETIME NULL ) GO IN...

Simple Max/Min type question Help!! Urgent!!
Hi everyone. I have 5 numbers from cell A1 to A5 A1 = 5 A2 = 13 A3 = 4 A4 = 1 A5 = 12 If I want to re-arrange them in cell B1 to B5 from smallest to largest. I know I can use sort function but.. how do I make it arrange in such way automatically? i.e. B1 will always have the smallest value from A1 to A5 so I can use B1=> =Min(A1:A5) B2 will always have the 2nd smallest value from A1 to A5 => Now I have a problem. Is there a formulae to find second smallest or biggest value? Please help Thank you, =SMALL(A1:A5,2) Cheers, JM "James8309" <jaedong1221@gmail.com> wro...

SSRS Advance Services and passing parameters via <form>
I'm new to SSRS. I'm using SQL Server Express with Advanced Services, and I have a report working. The report has a Parameter defined as "ReportDate". In the report design, I have a subheading expression that goes like this: ="For " & Parameters!ReportDate.Value I'm trying to invoke the report from an ASP.net MVC app like this: <form id="frmReader" action=" http://localhost:8080/Reports_SQLEXPRESS/Pages/Report.aspx?ItemPath=%2fReports%2fDonorAccountHistory " method="post" target="_blank&qu...

Question: Access & Publisher??
Hi out there... I've an Access database (some data is names/addresses/etc)... and a Publisher template (with 8-10 Styles). I want to make a phone directory. I've tried googling "Access to Publisher"... and came back with alot of Access->Word hits... Didn't come up with anything useful on Publisher-FROM-Access either. Can someone point me to where I should start?? Thanks in advance, Steve What version Publisher? In earlier versions you can use a straightforward mail merge. In Publisher 2003-07 Catalog Merge would be good. Publisher recognizes Access databa...

Very difficult query!
Hello All I have spent most of today on this and can't get it right: I hope someone out there can help! I need a query that will give a person's retirement date (RD), according to their date of birth (DOB). The trouble is that the age at which a person can retire is not constant, but is instead determined according to the following: for a DOB earlier than 6 April 1950, the RD is on their 60th birthday If DOB is 6 April 1950 to 5 May 1950, RD is 6 May 2010 If DOB is 6 May 1950 to 5 June1950, RD is 6 July 2010 If DOB is 6 June 1950 to 5 July 1950, RD is 6 Sep 2010 If DOB i...

Template & linked Excel database question
Okay - I got my template set up & linked to an Excel worksheet for a database. I open the template and start entering info - the first field is the client's name & has a macro that saves the file as "Name.xls" when moving out of this cell. I go on to complete the initial data entries, then save & close...but I don't get the prompt to save as a new entry to the database file UNLESS I then re-open the same file and close it again. Why don't I get the prompt the FIRST time I save & close???? tm ...

Basic Database Design Question
I'm setting up a new database with access 97. It will include several daily extract files (excel format) from several old mainframe machines. I have several ideas on how to do this, but none of them address the repetition of data in fields that could be referenced on another table. If I make reference tables, It decreases the data size significantly, but doesn't import the next day's excel file well. some background: there are 7000 unique client numbers, names, diagnoses, and other identifying information (2mb per extract). Each day I will receive an excel file that is nearly i...

Question about erase software.
I routinely wipe deleted data from the HDD over the weekend. For this I use "East-tec Eraser". But sometimes I get log reports such as the following: **** Decision:Ignore -> File Slack C:\Program Files\Common Files\Adobe\Help\de_DE\Acrobat Pro\8.0\WS58a04a822e3e50102bd615109794195ff-7dfd.html Cannot open file - Access is denied **** What does this mean? Is the Adobe software working in the background somehow? How can I turn this off temporarily? regards, Frank Adobe has a bad habit of putting a startup launcher in the Programs\Startup folder...

PivotTable "show data value as" question
Hi all, I have a problem about using Pivot Table in Excel 2003: In a pivot table I have a date field, grouped by year and month, as the row field. The data field of the table is anything that can be summed. Now when I tried to display the data field value as "Difference from previous month", I found that January of each year is always blank, ideally the data value in January should be display as the difference between the actual January value minus December value of the last year. Any tricks to show them? Thanks a lot. Frederick Chow Hong Kong. If you group the dates by ...

passing parameter to query problem
I've got a query set up to receive a parameter from a combo box on a form. The query works fine on its own, but every time it is run from the form, no data is represented. I have done this before, but I have never run into this problem. I have checked all the the names and the SQL, almost obsessively, and they're all correct. I just can't think of any other reason why the query will not accept a parameter from the form. Anyone have any suggestions? Are you sure that what the combo box is returning is what's in the table? Rermember that combo boxes have a BoundColumn. When ...

Question: Macro overloading, passing variable number of arguments
Excel-97 (SR-2) In general I would like to write macros that can be overloaded, for example Hyperlink() has an optional displaytext field. HyperLink( Filename) HyperLink( Filename, DisplayText) Please could someone post a short, useful macro that does such a thing, rather than give a description of how to do so. I have searched the online help for "overloading" and "arguments" but nothing useful is shown there. TIA, Fred. See the help for Functions You are just talking about optional arguments. Function MyFunc(MyStr As String, Optional MyArg1 As _ Integer = 5, _ ...

Running Sum in Union Query?
Hello, I have created a Union Query to consolidate results from separate queries, each one of which represents results for a single month: SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth1Total UNION SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth2Total UNION SELECT ReportMonth, MonthlyRev, MonthlyCost FROM qryMonth3Total; etc. This works very well for showing me monthly revenues vs. costs. However, I would also like to be able to create a similar Union Query that shows a running sum of the monthly revenue and costs. (Note: for reasons I won't get into here, I h...

HTML Source Code Question
In Publisher 98 or 2000 is there a way to view the HTML source code and then copy it into another document? Not within Publisher. It is not an html editor. Open the html files in Notepad or any text/html editor. -- David Bartosik - Microsoft MVP Visit www.davidbartosik.com for Publisher and Web Design Tips and How-to's. "Harvey" <hcohenREMOVE@eznet.THISnet> wrote in message news:0a3e62040b4377a8c82d327373486794@news.teranews.com... > In Publisher 98 or 2000 is there a way to view the HTML source code and then > copy it into another document? > > Harvey...

Package File Service Pack Inclusion
After applying SP3 to GP 10, is there any way to create a package file that includes the service pack or do you have to install the package file and immediately apply the service pack? Rich, You can create Installation package file for your V10. Then, Install the GP in Clients using the Installation package and then Apply Service Pack on their machines. For Service pack, You can use GP Automated Client Updates that will be helpful. -- Thanks Janakiram M.P. MCP-GP http://janakirammp.blogspot.com "Rich Wheeler" wrote: > After applying SP3 to GP 10, is there any way to c...

Black Viper web-site. Can anyone recommend it?
Hi. A guy I work with recommended to me a web-site called Black Viper. The web-site I found is: http://www.blackviper.com/ Does anyone recommend this site or can anyone authenticate it's information? I plan to check it out. Thank you. I haven't visited the site but looking at the name, it contains the word "Black" and so by definition it must be a very bad site. Anything black is generally treated as BAD in the western world. For example: Black day, Black monday etc etc. Even black cat brings bad luck if it crosses your path! hth Brian V wrote: ...

Unusual email configuration question
Hello I am new to exchange and have been given the task of implementing it within a small company. I am looking for advise regarding an unusual email arrangement. This company is split into two separate companies but several of the employee's work for both companies thus require to receive email from both domains, this is not a problem. The problem arises when sending an email, how can they choose which account to send it on, so the customer see's the correct address. They are used to using multiple accounts in outlook but I cannot see how this is possible in exchange. I look ...

BCC Question #2
Hello: Quick question regarding BCC and mail headers. BCC informtaion is obviously not stored in the header of the final recipient. Does exchange strip this information before delivery or is this handled in some other fashion? Thanks Yes, it is hidden as security measure, only shows in SMTP logs. James Chong MCSE M+, S+, MCTS, Security+ msexchangetips.blogspot.com Joe wrote: > Hello: > > Quick question regarding BCC and mail headers. BCC informtaion is obviously > not stored in the header of the final recipient. Does exchange strip this > information before delivery o...

Retrieving informations about opened web pages by Internet Explorer
Is there any way to retrieve how many web pages are opened by Internet Explorer, and what URLs are opened by it, from another process? I searched for IHTMLDocument5 and so on, however, I could't find any hint. Please reply. Thanks in advance. Regards, Hyun-jik Bae ...

Problem Setting-up Bank of America's online services in Money 2006
I migrated from Money 2005 to Money 2006 and I'm having problems with the automatic updates in my Bank of America (BOFA). Money 2006 doesn't recognize the previous online setup information and every time that I try to set up the online services for my BOFA account Money 2006 creates a new account and download last transactions. Is there a way to associate my existing BOFA account with the online set-up information? My BOFA account is not CA, WA, etc. Can someone help me? Thanks I just installed the MS Money 2006 and was unable to add the BoA a/c successfully. Although I was a...

Excel File Question
Rarely use Excel and would ask what is the difference between an excel spreadsheet and a workbook. Much thanks for an informed response. Its just terminology. People call an excel file a workbook or a spreadsheet. I tend to think that a spreadsheet is one tab of information in a workbook, so a workbook is a collection of related spreadsheets. "Maurice" wrote: > Rarely use Excel and would ask what is the difference between an excel > spreadsheet and a workbook. Much thanks for an informed response. When Excel first came out the files consisted of a single she...