function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MarkMCCMarkMCC 

Help With Query

have a chart displaying Sales Quota vs. Total Sales by month for each sales user (i pass in a REP_ID from the apex page).

 

 However the months display on the graph like...

 

Jan  Mar  Feb

 

How can i have it display in order by month?  Below is my current query.

 

SELECT Month__c, Quota__c, Sales__c From Sales_Quota__c Where Rep_Review__r.id = ' "

 

I cant add Order By Month__c at the end as it doesnt pull in the ID when i go to the APEX page.

 

Thanks for any help!

Jeremy_nJeremy_n

It sounds like you want a collection to be ordered by month order. It's hard to say what the best way to do that would be without seeing your code. Can you post the relevant parts of your page and controller?

 

Jeremy

MarkMCCMarkMCC

Thanks for the help! Below is the code and i highlighted the data query in red. The below works fine, however doesnt sort the months correctly.

 

Thanks,

Mark

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:salesforce="http://www.salesforce.com/" 
				layout="absolute"
				 applicationComplete="init()">
	
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import com.salesforce.results.QueryResult;
			import com.salesforce.results.LoginResult;
			import com.salesforce.AsyncResponder;
			import com.salesforce.objects.LoginRequest;
			
			[Bindable]
			private var opps:ArrayCollection;
			
			private function init():void 
			{
				var lr:LoginRequest = new LoginRequest();
				lr.session_id = parameters.sid;
				lr.server_url = parameters.surl;
				lr.callback = new AsyncResponder(loginHandler);
				force.login(lr);
			}		
			
			private function loginHandler(result:LoginResult):void 
			{
				force.query("SELECT Month__c, Quota__c, Sales__c From Sales_Quota__c Where Rep_Review__r.id = '"+
					parameters.aid + "'", new AsyncResponder(queryHandler));
			}
			
			private function queryHandler(result:QueryResult):void
			{
				opps = result.records;
			}
		]]>
	</mx:Script>
	
	<salesforce:Connection id="force"/>
	<mx:Panel title="LineChart Control" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="240"
			  paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center">
		
		<mx:LineChart id="linechart" color="0x323232" height="100%"
					  showDataTips="true" dataProvider="{opps}">
			
			<mx:horizontalAxis>
				<mx:CategoryAxis  categoryField="Month__c" />
			</mx:horizontalAxis>
			
			<mx:series>
				<mx:LineSeries yField="Sales__c" form="curve" displayName="Sales"/>
				<mx:LineSeries yField="Quota__c" form="curve" displayName="Quota"/>
				
			</mx:series>
		</mx:LineChart>
		
		<mx:Legend dataProvider="{linechart}" color="0x323232"/>
		
	</mx:Panel>	
</mx:Application>

 

Jeremy_nJeremy_n

What if you have a field on your Sales Quota object that contains an integer referring to the number of the month based on the month name. This could be a simple formula field. Then in your query, add "order by Month_Number__c".

 

Good luck,

 

Jeremy

MarkMCCMarkMCC

Where would the order by statement go?  Becuase I cant put it at the end as the ID that the page is passing doesnt work and it doesnt work if I add it before the Rep_Review__r.ID field.

Jeremy_nJeremy_n

It should go at the end of your query string. Are you saying you tried that and you got an error of some kind? What did you get? Be careful of leaving spaces between words.

 

Jeremy

 

 

MarkMCCMarkMCC

This is what I have and the data doesnt pull onto the chart.

 

 

SELECT Month__c, Quota__c, Sales__c From Sales_Quota__c Where Rep_Review__r.id =' Order By Month__c" +

Jeremy_nJeremy_n

Rep_Review__r looks like a relationship reference. I think you might want to replace "Rep_Review__r.id" with "Rep_Review__c" in your expression.

MarkMCCMarkMCC

The chart displays on an Object Called Rep Review.

 

The sales quotas are linked to the rep review object by a lookup field.

 

So I need to pull the sales quotas that have a rep review id of XXX

Jeremy_nJeremy_n

If your lookup field is called Rep_Review__c, then Rep_Review__c is the field that contains the ID you are looking for. Use that field, not the relationship reference you have now. Relationships and lookup fields are a little confusing sometimes.

 

Jeremy

Sandeep SankhlaSandeep Sankhla

Hello everone,

I am trying to query Quota but I am unable to query it.
Can anyone please tell me how to query quota .