• obrien
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

Hello - 

 

I've ran into a strange issue I haven't seen before when using a Javascript remote function to return the results of a query..

 

I have a method that returns the results of a query on the Opportunity object:

 

@RemoteAction
Public static AggregateResult[] myOppsQuery {
      List<AggregateResult> ar = [Select Calendar_Quarter(CloseDate)Quarter, Sum(Commissionable_Margin__c)Margin from Opportunity where CloseDate = THIS_YEAR AND isWon = TRUE Group By Calendar_quarter(CloseDate) Order by Calendar_quarter(CloseDate)];
      
      return ar;
}

 

 

When this method is invoked by the javascript remote function the results I am getting differ from the results of the query by itself. Copy/pasting the query from the method into SoqlXplorer returns the correct value, but the javascript remote function results are not the same.

 

Is there some sort of caching of a previous value going on here? I've cleared browser cache + tried different browsers but the issue persists. 

 

Thanks in advance for taking a look at this - any assistance is greatly appreciated.

  • April 02, 2013
  • Like
  • 0

Hello,

 

I have a custom VF page that I want all user profiles to view with the exception of two profiles. I have tried using || and an Else If statement to accomplish this but I receive errors for both.

 

Below is what I am trying to accomplish:

 

<apex:page action="{!if($Profile.Name != 'Profile1' || $Profile.Name != 'Profile2', null, urlFor($Action.Case.Tab, $ObjectType.Case,null, true))}"
    standardController="case" extensions="extension" recordSetVar="cases" tabStyle="Case">

 

Can this be done or will I have to do this in the extension?

 

Thank you

 

  • October 17, 2012
  • Like
  • 0

Hello,

 

I'm creating a page that is bound to a Case Standard Controller and I've created an extension to modify the "New Case" creation process. I want the users to be able to upload an attachment while filling out the New Case details but I've come across an issue. Here is the extension:

public class CaseExt{
    
    public ApexPages.StandardController controller {get;set;}
    public Case c {get;set;}
    public String userEmail;
    Public Attachment a {get;set;}

    public CaseExt(ApexPages.StandardController con){
        controller = con;
        c = (Case) controller.getRecord();
        a = new Attachment();
        userEmail = userInfo.getUserName();
    }
    
    public PageReference save(){
     List<Contact> cnt = [SELECT Id, Email, Name FROM Contact WHERE Email =: userEmail];
        if (cnt.size() < 1) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Your email address does not match our records. Please update your contact information.');
            ApexPages.addMessage(msg);
            return null;
        } else {
            try {
                c.ContactId = cnt.get(0).Id;
                INSERT c;  
                a.ParentId = c.Id;
                INSERT a;
                return page.CaseThankYou;           
            }catch (Exception e){
            ApexPages.addMessages(e);
            return null;
            }
        }
     }
}

 And the VF page:

<apex:page StandardController="case" extensions="CaseExt">
    <apex:form >
      <apex:pageBlock title="Submit A Case">
        <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!save}" value="Submit"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">                     
        <apex:inputfield value="{!c.type}" required="true"/>
        <apex:inputField value="{!c.priority}"/>
        <apex:inputField value="{!c.Subject}" required="true"/>   
        <apex:inputTextarea value="{!c.description}" rows="8" cols="50" />
        <apex:inputfile value="{!a.body}" filename="{!a.name}" />
        </apex:pageBlockSection>
     </apex:pageBlock>
   </apex:form>
</apex:page>

 

The issue I'm seeing is that when I save the record the attachment doesn't appear to be added to the case.. I can't seem to figure out why. Any help or recommendations are greatly appreciated.

 

Thank you 

 

 

J

  • October 13, 2012
  • Like
  • 0

Hello - 

 

I've ran into a strange issue I haven't seen before when using a Javascript remote function to return the results of a query..

 

I have a method that returns the results of a query on the Opportunity object:

 

@RemoteAction
Public static AggregateResult[] myOppsQuery {
      List<AggregateResult> ar = [Select Calendar_Quarter(CloseDate)Quarter, Sum(Commissionable_Margin__c)Margin from Opportunity where CloseDate = THIS_YEAR AND isWon = TRUE Group By Calendar_quarter(CloseDate) Order by Calendar_quarter(CloseDate)];
      
      return ar;
}

 

 

When this method is invoked by the javascript remote function the results I am getting differ from the results of the query by itself. Copy/pasting the query from the method into SoqlXplorer returns the correct value, but the javascript remote function results are not the same.

 

Is there some sort of caching of a previous value going on here? I've cleared browser cache + tried different browsers but the issue persists. 

 

Thanks in advance for taking a look at this - any assistance is greatly appreciated.

  • April 02, 2013
  • Like
  • 0

Hello,

 

I'm creating a page that is bound to a Case Standard Controller and I've created an extension to modify the "New Case" creation process. I want the users to be able to upload an attachment while filling out the New Case details but I've come across an issue. Here is the extension:

public class CaseExt{
    
    public ApexPages.StandardController controller {get;set;}
    public Case c {get;set;}
    public String userEmail;
    Public Attachment a {get;set;}

    public CaseExt(ApexPages.StandardController con){
        controller = con;
        c = (Case) controller.getRecord();
        a = new Attachment();
        userEmail = userInfo.getUserName();
    }
    
    public PageReference save(){
     List<Contact> cnt = [SELECT Id, Email, Name FROM Contact WHERE Email =: userEmail];
        if (cnt.size() < 1) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Your email address does not match our records. Please update your contact information.');
            ApexPages.addMessage(msg);
            return null;
        } else {
            try {
                c.ContactId = cnt.get(0).Id;
                INSERT c;  
                a.ParentId = c.Id;
                INSERT a;
                return page.CaseThankYou;           
            }catch (Exception e){
            ApexPages.addMessages(e);
            return null;
            }
        }
     }
}

 And the VF page:

<apex:page StandardController="case" extensions="CaseExt">
    <apex:form >
      <apex:pageBlock title="Submit A Case">
        <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!save}" value="Submit"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">                     
        <apex:inputfield value="{!c.type}" required="true"/>
        <apex:inputField value="{!c.priority}"/>
        <apex:inputField value="{!c.Subject}" required="true"/>   
        <apex:inputTextarea value="{!c.description}" rows="8" cols="50" />
        <apex:inputfile value="{!a.body}" filename="{!a.name}" />
        </apex:pageBlockSection>
     </apex:pageBlock>
   </apex:form>
</apex:page>

 

The issue I'm seeing is that when I save the record the attachment doesn't appear to be added to the case.. I can't seem to figure out why. Any help or recommendations are greatly appreciated.

 

Thank you 

 

 

J

  • October 13, 2012
  • Like
  • 0