How to Retrieve Random Records through webservice method

Hi All,

I'm writing an application that retrieve records from CRM 3.0 automatically 
using the web service. My question is, is there any way we can retrieve 
records randomly by using any webservice method? Like we can use RAND() or 
NEWID() to achieve this in SQL. Please help me if you have any idea about it. 

My sample method code is given below:

  CrmService service = new CrmService();
          
 RetrieveMultipleRequest request2 = new RetrieveMultipleRequest();


            // Create the ConditionExpression object.
            ConditionExpression condition = new ConditionExpression();

            // Set the condition to be the city equals Sammamish.
            condition.AttributeName = "new_accounttype";
            condition.Operator = ConditionOperator.Equal;
            condition.Values = new string[] {type };

            OrderExpression orderexp = new OrderExpression();
            orderexp.AttributeName = "name";
            orderexp.OrderType =  OrderType.Ascending;
                                              
            // Create the FilterExpression object.
            FilterExpression filter = new FilterExpression();

            // Set the filter's properties.
            filter.FilterOperator = LogicalOperator.Or;
            filter.Conditions = new ConditionExpression[] { condition };
     
            
            // Create the QueryExpression object.
            QueryExpression query = new QueryExpression();

            // Set the QueryExpression object's properties.
            query.EntityName = "account";
            query.ColumnSet = new AllColumns();
            query.Criteria = filter;
            query.Orders = new OrderExpression[] { orderexp }; 
       


               // Set the Request object's properties.
                   request2.Query = query;

             // Execute the request.
                RetrieveMultipleResponse response2 = 
(RetrieveMultipleResponse)service.Execute(request2);
           
                BusinessEntityCollection entities = 
response2.BusinessEntityCollection;



What i want, is to get accounts records in random order, what code should i 
add to the above method in order to achieve that. 

Thanks in advance.

Kind Regards,
-- 

Sol
0
Sol (12)
2/25/2008 6:04:00 AM
crm 35858 articles. 1 followers. Follow

2 Replies
662 Views

Similar Articles

[PageSpeed] 1

Hi Sol,

as far as I know, there is no way to randomise the order of records 
returned, however

> What i want, is to get accounts records in random order

if that's what you want then why don't you get the records as they come from 
the database, then simply randomise the order on the client's side?

Hope this helps
-- 
George Doubinski
CRM Certified Professional - Developer
Blog: http://crm.georged.id.au/


"Sol" <Sol@discussions.microsoft.com> wrote in message 
news:5A7A8A39-D7E1-45B7-AC31-3B2DDF75FB05@microsoft.com...
> Hi All,
>
> I'm writing an application that retrieve records from CRM 3.0 
> automatically
> using the web service. My question is, is there any way we can retrieve
> records randomly by using any webservice method? Like we can use RAND() or
> NEWID() to achieve this in SQL. Please help me if you have any idea about 
> it.
>
> My sample method code is given below:
>
>  CrmService service = new CrmService();
>
> RetrieveMultipleRequest request2 = new RetrieveMultipleRequest();
>
>
>            // Create the ConditionExpression object.
>            ConditionExpression condition = new ConditionExpression();
>
>            // Set the condition to be the city equals Sammamish.
>            condition.AttributeName = "new_accounttype";
>            condition.Operator = ConditionOperator.Equal;
>            condition.Values = new string[] {type };
>
>            OrderExpression orderexp = new OrderExpression();
>            orderexp.AttributeName = "name";
>            orderexp.OrderType =  OrderType.Ascending;
>
>            // Create the FilterExpression object.
>            FilterExpression filter = new FilterExpression();
>
>            // Set the filter's properties.
>            filter.FilterOperator = LogicalOperator.Or;
>            filter.Conditions = new ConditionExpression[] { condition };
>
>
>            // Create the QueryExpression object.
>            QueryExpression query = new QueryExpression();
>
>            // Set the QueryExpression object's properties.
>            query.EntityName = "account";
>            query.ColumnSet = new AllColumns();
>            query.Criteria = filter;
>            query.Orders = new OrderExpression[] { orderexp };
>
>
>
>               // Set the Request object's properties.
>                   request2.Query = query;
>
>             // Execute the request.
>                RetrieveMultipleResponse response2 =
> (RetrieveMultipleResponse)service.Execute(request2);
>
>                BusinessEntityCollection entities =
> response2.BusinessEntityCollection;
>
>
>
> What i want, is to get accounts records in random order, what code should 
> i
> add to the above method in order to achieve that.
>
> Thanks in advance.
>
> Kind Regards,
> -- 
>
> Sol 


0
2/25/2008 1:17:06 PM
Hi George,

Many Thanks for your reply. Yeah, i can rendomise them on client side, i 
just wanted to reduce the processing time.


Again thanks for your time.


-- 

Sol


"George Doubinski" wrote:

> Hi Sol,
> 
> as far as I know, there is no way to randomise the order of records 
> returned, however
> 
> > What i want, is to get accounts records in random order
> 
> if that's what you want then why don't you get the records as they come from 
> the database, then simply randomise the order on the client's side?
> 
> Hope this helps
> -- 
> George Doubinski
> CRM Certified Professional - Developer
> Blog: http://crm.georged.id.au/
> 
> 
> "Sol" <Sol@discussions.microsoft.com> wrote in message 
> news:5A7A8A39-D7E1-45B7-AC31-3B2DDF75FB05@microsoft.com...
> > Hi All,
> >
> > I'm writing an application that retrieve records from CRM 3.0 
> > automatically
> > using the web service. My question is, is there any way we can retrieve
> > records randomly by using any webservice method? Like we can use RAND() or
> > NEWID() to achieve this in SQL. Please help me if you have any idea about 
> > it.
> >
> > My sample method code is given below:
> >
> >  CrmService service = new CrmService();
> >
> > RetrieveMultipleRequest request2 = new RetrieveMultipleRequest();
> >
> >
> >            // Create the ConditionExpression object.
> >            ConditionExpression condition = new ConditionExpression();
> >
> >            // Set the condition to be the city equals Sammamish.
> >            condition.AttributeName = "new_accounttype";
> >            condition.Operator = ConditionOperator.Equal;
> >            condition.Values = new string[] {type };
> >
> >            OrderExpression orderexp = new OrderExpression();
> >            orderexp.AttributeName = "name";
> >            orderexp.OrderType =  OrderType.Ascending;
> >
> >            // Create the FilterExpression object.
> >            FilterExpression filter = new FilterExpression();
> >
> >            // Set the filter's properties.
> >            filter.FilterOperator = LogicalOperator.Or;
> >            filter.Conditions = new ConditionExpression[] { condition };
> >
> >
> >            // Create the QueryExpression object.
> >            QueryExpression query = new QueryExpression();
> >
> >            // Set the QueryExpression object's properties.
> >            query.EntityName = "account";
> >            query.ColumnSet = new AllColumns();
> >            query.Criteria = filter;
> >            query.Orders = new OrderExpression[] { orderexp };
> >
> >
> >
> >               // Set the Request object's properties.
> >                   request2.Query = query;
> >
> >             // Execute the request.
> >                RetrieveMultipleResponse response2 =
> > (RetrieveMultipleResponse)service.Execute(request2);
> >
> >                BusinessEntityCollection entities =
> > response2.BusinessEntityCollection;
> >
> >
> >
> > What i want, is to get accounts records in random order, what code should 
> > i
> > add to the above method in order to achieve that.
> >
> > Thanks in advance.
> >
> > Kind Regards,
> > -- 
> >
> > Sol 
> 
> 
> 
0
Sol (12)
2/27/2008 10:18:01 AM
Reply:

Similar Artilces:

How to retrieve the string from dialog box
Hi All, Does anyone know how to retrieve a string in IDC_STATIC on a dialog box? I have to print out a report with an application version at the bottom line for users to be aware of it in my application. I don't know how to retrieve the string in IDC_STATIC control on a dialog box. It would be very nice that someone let me know how to do that without calling the dialog box. TIA Hwasoo Lee Back 9 wrote: > Hi All, > > Does anyone know how to retrieve a string in IDC_STATIC on a dialog box? > I have to print out a report with an application version at the bottom line &g...

How do I get the macro "stop recording" tool bar back?
While recording a macro in excel (11.63...), I clicked the X (close button) and now can not get the "stop recording" macro tool bar to show. I would like to use the tool bar for the reference button. Hi choose tools / macro / record new macro click OK now display the stop recording toolbar (view / toolbars / stop recording) now click on the little blue square box and everything should be fine again when you next go to record a real macro Cheers JulieD "RBD04" <RBD04@discussions.microsoft.com> wrote in message news:67DA2DFF-6EA7-41CD-88B6-636B5B7A0C76@microsoft....

How to determine if subform has record or not
Hi, I have a Master/Sub form for data entry. Before doing data entry, I want to check the number of record of the subform, If subform is empty then add commune names that belong to the Master ID project thru append query (So that user will have a list of communes ready) SF One way is to check the RecordCount of the subform's recordset: If Me.SubformName.Form.Recordset.RecordCount = 0 Then ' no records Else ' at least one record End If where SubformName is the name of the subform control (the control that holds the subform object). -- Ken Snell <MS ACCESS ...

Incorrect record length #2
Hi all, I'm using GP 9.0 and i'm getting this error when trying to run PURCHASING reports. "An open operation on table 'TX_Detail_Period_SUM_TRX' has an incorrect record length." I tried to find this table in the database but couldn't find it. I searched the Knowledge base for this error but didn't find any article related to this particular table. Any insight? thank you, Eduardo This table is a temp table that is created in your local temp folder (not sql). The problem is that you have old temp files laying around and now when GP tries to make...

retrieve an AVERAGE of a range using VLOOKUP to locate start/end d
Can I calculate the average of a range based on VLOOKUP? In other words, can I get Excel to "look up" the respective START / END dates of an investment position listed in Sheet 1 and then go and locate those 2 distinct cell values in in a different sheet (Sheet 2) utilizing VLOOKUP function and then return the calculated AVERAGE of the cells within that range back into Sheet 1? Appreciate any thoughts if doable in Excel in any way? tAKE A LOOK AT AverageIFS and see if that does what you want. If it were me, I'd probably enter the formula manually, record the resu...

Count records in a query
Hello! I have a query that runs pretty slow, and I'd like to alert the user before running the query. So I have a source query for my slow query, and I'd like to count the records in my source query and estimate the time the query will take to run. How can I do this in VBA? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201005/1 DCount("*","Your Source Query Name") This will give you the number of records in the Query "AtleDreier via AccessMonster.com" wrote: > Hello! >...

selecting an item at random for QA sampling
A co-worker has asked for help speeding up a process for QA of images of scanned documents. She does an end-of-line QA check on a set number of document images selected from a report in a simple spreadsheet. The numbers of significance to her from this report are in columns A to C and these are Batch #, DCN (document control number), and Image Count. The report has a varying number of batches reported on it, though typically there are thousands of batches. The DCN listed for each batch is the first document control number in the batch. The rest of the images in a batch have seq...

Retrieve mouse position
Hi, I am writing an app in which I need to retrieve the mouse coordinates even when it mouse is outside the main frame. How do I do it? Thanks! xg >Hi, I am writing an app in which I need to retrieve the mouse coordinates >even when it mouse is outside the main frame. How do I do it? Thanks! Have you tried calling GetCursorPos? If you want to know when the mouse is moving I think you'll need to use a hook - have a look at SetWindowsHookEx WH_MOUSE. Dave IN addition to David's answer, you have not stated the problem you are trying to solve. For examp...

Massive Random Upgrade Corruption in Money 2005
In going from Money 2004 to 2005 I am getting random corruption. I have done the upgrade multiple times and get different results each time. There are three main problems that I have been able to identify already. 1. Opening Balances on accounts reset to 0. 2. Upcoming bills duplicated up to 10 times. 3. Categories duplicated up to 5 times. All 3 problems can be time consumingly repaired manually. However I have a fear of the problems I don't see. Also it really scares me that it changes everytime I do the upgrade. I have been using Money since '97 and have had little problem...

Retrieving comment using range name
I have singular cells in different places referenced by their range names. Is there a way to get the comments corresponding to the referenced ranges (singular cells)? Thanks in advance, Tomek Set testrng = Range("A3:A4", "C3:C4") comment1 = testrng(1).Comment.Text .... commentn = testrng(n).Comment.Text Stefi „topola” ezt írta: > I have singular cells in different places referenced by their range > names. Is there a way to get the comments corresponding to the > referenced ranges (singular cells)? > Thanks in advance, > Tomek > > did yo...

Retrieving messages
Help, I mistakenly restored all the defaults on Outlook (the computer did not crash) losing all the messages and address book. I have had to set up the application from scratch entering account details etc. Question is: are all the messages and contacts still held on the computer even the program needs to be set up again and, if so, how do I retrieve them. Any assistance greatly appreciated. Thanks. P89 If you made a backup of your system or My Documents, search for a file called Outlook.pst. If you have that you can import all the information. Al "peterson89" <peterson...

Retrieve
Hi how do i retrieve all the postings i have posted in this group. sometimes forget of where i posted my i will be glad to get to know how to pull out my own questions cheers Click on your name to view the profile...Then click 'Recent posts by this user' http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.excel.misc&p=1&tid=467a932d-65b6-4bb1-98e1-25def53a971a&mid=467a932d-65b6-4bb1-98e1-25def53a971a -- Jacob (MVP - Excel) "Amin" wrote: > Hi how ...

Prevent Appending Certain Records
I trying to prevent appending any records from my temp table into my perm table that have the same run date. I thought this would do it, but no luck INSERT INTO RunDate, Customer, City, State SELECT RunDate, Customer, City, State FROM tblTemp WHERE tblTemp.RunDate<>[tblPerm]![RunDate]; I know identifying a primary key in my Perm table would prevent duplicates, but in this case getting a primary key is impossible and the best I can do is prevent the user from appending records that have been "run" on the same date twice. On Fri, 20 Apr 2007 11:28:01 -0700, Kirk P. <K...

Retrieving lost messages after Synchronization in Outlook Express
Setup for my hotmail messages to be downloaded to Outlook Express. When tried to connect to see an old message, didn't realize that it was setup to auto synch. My messages were deleted from hotmail, and are now lost on Outlook Express after synching. Is there anyway to retrieve the lost messages from Outlook Express? I really needed some of the items in there, and had downloaded them so they wouldn't be lost. Thanks! ...

code for moving to new record in datasheet view
Access 2003 What's the vba code for moving to a new record when in datsheet view. Here's what I've tried but is errors saying the subform is not opened and yet this code is on an event in the subform: If cmbInvLU <> 289 Then DoCmd.GoToRecord acForm, "Forms!frmWOTRH![frmWOTRL subform].Form", acNewRec Thanks for your help. SAC, Since your already in the subform... try... DoCmd.GoToRecord , , acNewRec -- hth Al Campagna Microsoft Access MVP 2006-2009 http://home.comcast.net/~cccsolutions/index.html &quo...

Retrieving
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 ...

No free/busy information could be retrieved
Recently migrated from 5.5 to exch2003, once the 5.5 machine was turned off, users free/busy information is not available, if the 5.5 machine is turned on it is available, does anyone know what I need to so that the information is available after 5.5 is turned off? -- Thanks Sounds like you forgot to re-home the System Public Folders (specifically the Free/Busy Public Folder) before turning the old server off. Follow the details in this article for a list of things you should do in order to retire the 5.5 server. http://support.microsoft.com/default.aspx?scid=kb;en-us;307917 - referen...

Payable Transaction Record
I have lots of records in PM transaction table (PM00400) but they do not appear on payable transaction window. What could be the cause?? When I clicked each voucher number from payable transaction entry screen I can see them fine. When I try to post the bacth, a message pop up saying data entry errors exists in a batch use batch recovery window. How could I find where the error is? I recovered the batches but couldn’t post them. Any help is greatly appreciated. Print the batch edit report. This usually identifies errors prior to posting. -- Richard L. Whaley Author / Consultant / ...

Cost Update Method
I'm using POS 2.0. The manual and the help information indicate you should be able to update costs throught the Store Settings > Options > Inventory screen. I do not have the 'Cost update method" options listed on that screen. How can I have my costs updated using the weighted average method? Go to File>Configuration>Inventory, in Store Operations Manager. You should be able to select Weighted Average as your Cost Update Method. "BikeShop" wrote: > I'm using POS 2.0. The manual and the help information indicate you should > be able to up...

Unique Random Number Generator
I'm looking for a macro that will generate a unique Random number between 1-2000. The random aspect is obviously not the problem, the unique requirement is whats got me stumped. Thanks Tom. What about using RANDBETWEEN function? It is not a macro but it appears to suit your need. RANDBETWEEN(bottom,top) Bottom is the smallest integer RANDBETWEEN will return. Top is the largest integer RANDBETWEEN will return. Example 1 2 3 A B Formula Description (Result) =RANDBETWEEN(1,100) ...

retrieving my questions
I am still learning how to use this system to it's fullest. How can I locate the questions I have asked in the past? Is there an easy way? -- Zunibear in Montana It depends upon how you are viewing this forum. If using Outlook Express, make sure your view is set for all messages. You could then sort by "From". If you don't want to loose the threaded response view, don't sort, but you probably have a copy of any post you did in the "Sent Items" folder in Outlook Express. Look there, find the one you are interested in, and scroll to that date in the f...

Running Total of Random Number
Hi, I am trying to create a probablity simulation for a high school lesson. It involves rolling 1/2 dice using the randbetween function to create the die value. I want to keep a running total of the outcomes 1-6 in a cell for each which is linked to a chart. Is this possible? Do you mean a running total of all the values from the dice, if so do tools>options>calculation and check iteration and change from 100 to 1, assume randbetween formula is in A1 and you want the running total in B1, in B1 put =A1+B1, press F9 to calculate Regards, Peo Sjoblom "Mr H" wrote: &...

How to retrieve SYSTEMTIME
When I use: SYSTEMTIME st; MyTime = CTime::GetCurrentTime(); MyTime.GetAsSystemTime(st); st.wHour, st.wMinute,st.wSecond are correctly loaded but st.wMilliseconds is always 000. What am I doing wrong? Ron H. x-- 100 Proof News - http://www.100ProofNews.com x-- 30+ Days Binary Retention with High Completion x-- Access to over 1.9 Terabytes per Day - $8.95/Month x-- UNLIMITED DOWNLOAD On Fri, 16 Sep 2005 10:30:03 -0500, "Ron H" <rharshbarger@mmm.com> wrote: >When I use: > > SYSTEMTIME st; > MyTime = CTime::GetCurrentTime(); > MyTime.GetAsSys...

Current Record in Visual Basic....
Okay, I have a database which offers user to add suggestions to the database. If a new suggestion is added, it check a box within the table marked "activesuggestion" - is it possible to write some sort of code that only shows the label and text box in my form (label says "new suggestions" and text box had the total number of new suggestions in it) when a new suggestion has been added. What I want is, if there are no new suggestions or "activesuggestions" checked within the table, then the label and text box to be hidden, but when a new suggesti...

How do I retrieve
Is there a way to restore emails that were in the inbox before I did an easy transfer. System is Windows 7 with Outlook 2007 niether Easy Transfer or copy has any impact on the origonal data, which remains in the origonal PC (unless you did something else to it) "Glenn" <Glenn@discussions.microsoft.com> wrote in message news:0A92A4E7-6B84-4E2E-AD46-65544E08A801@microsoft.com... > Is there a way to restore emails that were in the inbox before I did an > easy > transfer. System is Windows 7 with Outlook 2007 Do you still have access to the origina...