• gslater
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 5
    Replies

I'm calling the webservice in curl like this:

 

curl "https://na12.salesforce.com/services/apexrest/****/profiledata?PARAM1=12345&PARAM2=DUMMY&LAST_SYNC_DATETIME=2012-07-22T09:00:00Z" -k -H 'Authorization: Bearer <SESSIONID> -H "X-PrettyPrint: 1"

 

where <SESSIONID> was obtained from calling UserInfo.getSessionId() from Execute Anonymous in Eclipse.

However it always fails with errorCode "INVALID_SESSION_ID" and message "Session expired or invalid".

 

Where am I going wrong?  I couldn't make sense of OAuth but I read in the docs you could just replace OAuth with Bearer and a sessionId for testing purposes.

I want the queries in my web service to only return the results to which the logged-in user has access.

 

I know I can use the with sharing keyword in a global class.

 

However the docs state "Because these rules aren't enforced, developers who use Apex must take care that they don't inadvertently expose sensitive data that would normally be hidden from users by user permissions, field-level security, or organization-wide defaults. They should be particularly careful with Web services, which can be restricted by permissions, but execute in system context once they are initiated."

 

Does this mean that webservices always return all records when queries are performed?

We're trying to synchronize SFDC and another application with the REST API (although I might be able to use SOAP).

 

Basically we have a Visualforce page which acts like a detail page for an object, showing all the field labels and their values.

 

If a new field is added/removed, its name is changed or a user gains/loses access to these fields, I need to be able to track these changes.  I also need to track Picklist values and dependencies.  An external application will then check for changes for a particular user and the webservice should send them back in the response.

 

I saw that there was a describeLayout() API call but I assume that

a) This is only available for SOAP

b) This would only return SFDC Page Layouts, not layouts within a Visualforce page.

 

Can anyone give me any tips?

We're doing a custom Lead Convert through Apex code.  We use setConvertedStatus = 'Qualified' when we convert the Lead.  This works fine.  The thing is, when we query for the Converted Lead in execute anonymous with:

 

Lead l = [Select Status, isConverted from Lead where Id = :convertedId];

 

isConverted is true, but the Status does not change to Qualified, despite this being a valid option in the picklist.  Instead, it remains as "Open" which is a non-converted Status.

 

I thought Lead.Status changes to reflect LeadConvert.setConvertedStatus ?

I'm trying to create an Opportunity Product (OpportunityLineItem) but for some reason it isn't accepting the Product2 field.  I know this field exists because it is standard but for some reason it isn't in the schema.  At first I thought it might have something to do with permissions but I have admin privileges and if I look at the field accessibility visibility is set to true for all profiles.  Here's the code (l is a Lead and pbe is a PricebookEntry).

 

OpportunityLineItem oli = new OpportunityLineItem();
            oli.Quantity = l.Units__c;
            oli.Roll_Call__c = l.Roll_Call__c;
           oli.Product2 = pbe.Product2Id;            //explodes here
            oli.Product_Code__c = l.Product_Code__c;
            oli.OpportunityId = leadOpportunityIds.get(l);

 

And it won't compile: Invalid field Product2 for Sobject OpportunityLineItem

Test.startTest();
        
        System.debug('$$$About to convert: '+lc);
        
        Database.LeadConvertResult[] lcr = Database.convertLead(lc);        
        
        for(Integer i = 0; i<lcr.size()-1; i++){
            System.debug('###$$$' + lcr[i]);
            System.debug('Success? '+lcr[i].isSuccess());
        }
        
Test.stopTest();

 

lc is an Array of LeadConvert objects, and the convertLead operation is correctly processing 4 Leads. All are successful from the LeadConvertResult output, and all get the correct Account and Contact populated (I set Opportunity not to insert).

 

Problem is - the after update trigger I wrote on Lead is being called 4 separate times (i.e. Trigger.new size is 1 every time).  I don't know why this would be as from the docs you can do a bulk convert.  I don't understand why the trigger is not receiving all converted Leads at once.

 

Can anyone help?

 

Edit: when trigger is called 4 separate times, it is not the same record that is being processed but the 4 separate records.

 

Let me see if I have this right. 

 

We have a lot of classes/triggers, and a lot of batches.  We also have a lot of managed packages with code hidden.

 

So when I get a test failing and the message 'System.Exception: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation. ' it should be easy right?  Identify the failing batch, use an if(Test.isRunningTest()) -> Limit 200 and done.

 

But how do you identify the batch that's failing?  There's no line number in the error message, and the ridiculous 1.9Mb limit of the debug log shows approximately nothing (even with log filters - blame static variables for that).  What's more, the batch could be in a managed package where I can't see the code.   I'd If anyone has any tips as to how I can get the failing batch I would be very grateful!

Basically I want to redirect to standard New page when a certain record type is selected, and a custom VF page when a different record type is selected.  Here's my VF

 

<apex:page standardController="Award_Nominations__c" action="{!IF(!isPClubAward, pageRedirect, URLFOR('/apex/Pclub_Awards',null,[retURL=RetUrl, RecordType=pRecordType],true))}" extensions="SBS_Award_New_Redirect">
</apex:page>

 

The URLFOR part works fine, but if I use URLFOR for the standard new page I get the record type selection page twice.  So I thought to add a method that returns a PageReference, pageRedirect:

 

 

public PageReference pageRedirect(){
        
        String prefix = Award_Nominations__c.Sobjecttype.getDescribe().getKeyPrefix();
        String param = '&CF00N40000002BitJ='+pAwrName+'&CF00N40000002BitJ_lkid='+pAwrId+'&retUrl='+pretUrl+'&RecordType='+pRecordType;
        
        return new PageReference('/'+prefix+'/e?nooverride=1&'+param);

 

 

I've tried pageRedirect, !pageRedirect and {!pageRedirect} in the VF without success.  The error either says:

 

Unknown Property Award_Nominations__cStandardController.pageRedirect OR

Save error: Syntax error

 

OR if I change the PageReference to a variable instead of a mehtod with a getter it complains that it receives Text instead of Object.

 

What's the right way to do this?

 

I'm planning to build a Visualforce page with a lot of different apex:components.

 

Some components are going to be a Select(Count) of certain records, which may be over 50,000.   To get around the governor limit restrictions, I was thinking of using the @ReadOnly annotation/page mode, as it increases the limits to 1 million and I'm not performing DML with this Count.

 

However, in another, unrelated component on the same page I will be displaying a Datatable with much fewer records (around 20) with DML Operations.  I figure that if I make the whole page Read-only, I will not be able to perform this DML. It seems that both work without the other, but put together they don't.

 

Is there a way to make certain components/controllers Read-Only and others not?  I read that you can use @ReadOnly as a class annotation but that a) This was only available as a webservice, and b) The docs say "if a Visualforcepage calls a Web service that contains the@ReadOnly

annotation, the request fails because Visualforce is the top level request, not the Web service" which is basically what I was planning on doing.

 

Is there any workaround for this?

In the report builder I have a chart based on report data, and I'm trying to filter out all the results where a certain picklist value is not defined (null).

 

So in the Report filters I added the condition if Picklist_Value__c does not equal "" .  This had the desired effect in the report's chart as all non-defined picklist values were filtered out. 

 

However, when I go to the Dashboard, import the report (refreshing just to be sure) the data appears with the null values unfiltered.  I don't understand why it would not be the same as the diagram in the report, but maybe it has to do with the fact that there is a hyphen.  I.e. it says that hyphen (-) has 21 results, valueA 13, valueB 6 etc... so it is not passing the filter.

 

Obviously I can't filter with a hyphen because it isn't a valid picklist value.  How do I prevent null results from appearing in my Dashboard?

Hi,

 

I'm looking to create a burndown chart, from a report if possible.  Something like http://www.invisible-city.com/sharon/uploaded_images/SampleBurndownChart.jpg

 

I have a 20 "Day" fields (Day1, Day2, Day3 etc) for each parent object which are all of type Percent.  Basically I am looking for the X-axis to contain the days and the Y-axis to contain percentages (0-100).  I can't seem to get this to work from a report though as it constantly shows "Record Count" and I seem to only be able to summarize one field.

 

Is this even possible in Salesforce?  How would I set about it?

 

Thanks in advance. 

 

 

We're doing a custom Lead Convert through Apex code.  We use setConvertedStatus = 'Qualified' when we convert the Lead.  This works fine.  The thing is, when we query for the Converted Lead in execute anonymous with:

 

Lead l = [Select Status, isConverted from Lead where Id = :convertedId];

 

isConverted is true, but the Status does not change to Qualified, despite this being a valid option in the picklist.  Instead, it remains as "Open" which is a non-converted Status.

 

I thought Lead.Status changes to reflect LeadConvert.setConvertedStatus ?

In the report builder I have a chart based on report data, and I'm trying to filter out all the results where a certain picklist value is not defined (null).

 

So in the Report filters I added the condition if Picklist_Value__c does not equal "" .  This had the desired effect in the report's chart as all non-defined picklist values were filtered out. 

 

However, when I go to the Dashboard, import the report (refreshing just to be sure) the data appears with the null values unfiltered.  I don't understand why it would not be the same as the diagram in the report, but maybe it has to do with the fact that there is a hyphen.  I.e. it says that hyphen (-) has 21 results, valueA 13, valueB 6 etc... so it is not passing the filter.

 

Obviously I can't filter with a hyphen because it isn't a valid picklist value.  How do I prevent null results from appearing in my Dashboard?

Test.startTest();
        
        System.debug('$$$About to convert: '+lc);
        
        Database.LeadConvertResult[] lcr = Database.convertLead(lc);        
        
        for(Integer i = 0; i<lcr.size()-1; i++){
            System.debug('###$$$' + lcr[i]);
            System.debug('Success? '+lcr[i].isSuccess());
        }
        
Test.stopTest();

 

lc is an Array of LeadConvert objects, and the convertLead operation is correctly processing 4 Leads. All are successful from the LeadConvertResult output, and all get the correct Account and Contact populated (I set Opportunity not to insert).

 

Problem is - the after update trigger I wrote on Lead is being called 4 separate times (i.e. Trigger.new size is 1 every time).  I don't know why this would be as from the docs you can do a bulk convert.  I don't understand why the trigger is not receiving all converted Leads at once.

 

Can anyone help?

 

Edit: when trigger is called 4 separate times, it is not the same record that is being processed but the 4 separate records.

 

Let me see if I have this right. 

 

We have a lot of classes/triggers, and a lot of batches.  We also have a lot of managed packages with code hidden.

 

So when I get a test failing and the message 'System.Exception: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation. ' it should be easy right?  Identify the failing batch, use an if(Test.isRunningTest()) -> Limit 200 and done.

 

But how do you identify the batch that's failing?  There's no line number in the error message, and the ridiculous 1.9Mb limit of the debug log shows approximately nothing (even with log filters - blame static variables for that).  What's more, the batch could be in a managed package where I can't see the code.   I'd If anyone has any tips as to how I can get the failing batch I would be very grateful!

Basically I want to redirect to standard New page when a certain record type is selected, and a custom VF page when a different record type is selected.  Here's my VF

 

<apex:page standardController="Award_Nominations__c" action="{!IF(!isPClubAward, pageRedirect, URLFOR('/apex/Pclub_Awards',null,[retURL=RetUrl, RecordType=pRecordType],true))}" extensions="SBS_Award_New_Redirect">
</apex:page>

 

The URLFOR part works fine, but if I use URLFOR for the standard new page I get the record type selection page twice.  So I thought to add a method that returns a PageReference, pageRedirect:

 

 

public PageReference pageRedirect(){
        
        String prefix = Award_Nominations__c.Sobjecttype.getDescribe().getKeyPrefix();
        String param = '&CF00N40000002BitJ='+pAwrName+'&CF00N40000002BitJ_lkid='+pAwrId+'&retUrl='+pretUrl+'&RecordType='+pRecordType;
        
        return new PageReference('/'+prefix+'/e?nooverride=1&'+param);

 

 

I've tried pageRedirect, !pageRedirect and {!pageRedirect} in the VF without success.  The error either says:

 

Unknown Property Award_Nominations__cStandardController.pageRedirect OR

Save error: Syntax error

 

OR if I change the PageReference to a variable instead of a mehtod with a getter it complains that it receives Text instead of Object.

 

What's the right way to do this?

 

In the report builder I have a chart based on report data, and I'm trying to filter out all the results where a certain picklist value is not defined (null).

 

So in the Report filters I added the condition if Picklist_Value__c does not equal "" .  This had the desired effect in the report's chart as all non-defined picklist values were filtered out. 

 

However, when I go to the Dashboard, import the report (refreshing just to be sure) the data appears with the null values unfiltered.  I don't understand why it would not be the same as the diagram in the report, but maybe it has to do with the fact that there is a hyphen.  I.e. it says that hyphen (-) has 21 results, valueA 13, valueB 6 etc... so it is not passing the filter.

 

Obviously I can't filter with a hyphen because it isn't a valid picklist value.  How do I prevent null results from appearing in my Dashboard?