• DaveHagman
  • NEWBIE
  • 49 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 18
    Replies

So I have a class that contains a bunch of methods for performing actions on cases (sending emails, verification etc). Now I have a bunch of private final variable at the top that I want to create getters for but when I try to return the  value from a method in the same class I get this error: 

Save error: Variable does not exist: this.MBI_ID

 

Now the variable is declared private but I am accessing it within the same class. For some reason it does not see it. I have tried to return with and without the "this" keyword and it still does not work. I hope I am not just having a complete n00b moment here but any help would be appreciated. I posted a snippet below. Thanks in advance!

 

 

public with sharing class CaseUtils {
   final String MBI_ID = '0013000000XXXXXXXXX';
   
   public static String getMbiAcctId()
   { return MBI_ID; } // Tried with and without "this" keyword
}
   

 

 

Hi All,

 

For some reason I cannot remember how to restrict what record types are allowed in the portal. How is this done?

Hey All,

 

I have a trigger set on a custom object called Feature_Setup__c. The details of what the object does isn't really relevant but the main purpose of the trigger is to send an email whenever one of these objects is created. I have a custom email template setup and I am setting the WhatId for the SingleEmailMessage to the Id of the Feature_Setup__c object. When I do this and then call the Messaging.SendEmail() method I get the following exception:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger New_Feature_Setup_Send_Email caused an unexpected exception, contact your administrator: New_Feature_Setup_Send_Email: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: []: Trigger.New_Feature_Setup_Send_Email: line 46, column 17

 

The exception is saying that WhatId is not available for sending emails to UserIds.  I am not using the WhatId to send to a User it is set to the Id of my custom object. Anyone have any ideas on what this exception could mean? I'm at a loss.

Hi All,

 

I am trying to create a trigger on the CaseSolution object in SF. I am using the Force.com IDE plugin for eclipse. When I go to create a new trigger, CaseSolution is not in the list of available objects. I ran updates for the IDE to make sure there were no updates from SF and there were none. Is there a reason that I can't create a trigger on this object? Has anyone else ran into this before?

Linking a VF page to a custom button on the Case page seems like an easy task. I create a new custom button, created multiple VF pages to link the button to but when I choose "Visualforce Page" for the button's Content Source field none of my vf pages appear in the drop down. I have made sure that the pages are available to everyone (In the security section for your VF page). Is there something that I'm missing? Sorry if this is a really dumb issue but I know I must be overlooking something really basic.

 

 

Hi All,

 

I am new to VisualForce and I am still going through some testing with it to get more familiar. I am making a simple page where the user will enter a contact name and a list of all contacts that match the criteria will be displayed (in a dataTable). I setup my custom controller and wrote some VF markup for the page but I am getting the following error: 
Error: Could not resolve the entity from <apex:inputField> value binding '{!accountName}'. inputField can only be used with SObject fields.

 

I'm not sure what this means. My sample code is below. Does anyone have any suggestions?

 

 

Custom Controller

 

public class CardholderVfController {
    private String accountName;
    private List<String> accountList;
    private String contactName;
    private List<String> contactList;
    private final Case c;  
    
    //public CardholderVfController(ApexPages.StandardController stdController)
    //{
        //this.c = (Case)stdController.getRecord();
        //accountList = new List<String>(new String[] {'Test1', 'Test2'});
    //}
    
    public List<String> getAccounts()
    {
        accountList = new List<String>(new String[] {'TestAccountText1', 'TestAccountText2'});
        return this.accountList;
    }   
    
    public List<String> getContacts()
    {
        return this.contactList;
    }
    
    public void setAccountName(String s)
    {
        accountName = s;
    }
    
    public String getAccountName()
    {
        return this.accountName;
    }
    
    

}

 Page Markup

 

<apex:page controller="CardholderVfController">
<apex:form >
    <apex:pageBlock > 
    <apex:pageBlockSection >
        <apex:inputField id="accountNameField" value="{!accountName}"/>
        <apex:commandButton id="findAccount" title="Search"/>
    </apex:pageBlockSection>
    <apex:pageBlockSection >
            <apex:dataTable align="center" value="{!accounts}" var="a" >
                <apex:column value="{!a}"/>
            </apex:dataTable> 
    </apex:pageBlockSection>            
    </apex:pageBlock>
    {!accounts[0]}
</apex:form>
</apex:page>

 

 

 

Hi all,

 

I was doing some research to try and find the best (In this case "best" means easiest to read) way to provide an error message to a user . I have a trigger where I want to display a clear error message to the user if a defined maximum has been reached. When you throw an exception a long very confusing looking error message is displayed to the user detailing the trigger name, line number of the error etc. I really only want to display the exception's message, not all of the other details. Is there any way to do this? If not, what are other methods of informing the user that an error has occurred? Is there any way to call a message box from a trigger? I know I can use java script when the action is tied to a button to display a message box but this is a trigger, not a class. 

Hi All,

 

I am trying to use the email field under the User object to send an outgoing single email message. The problem I am having is that when I query for the email address in the User table the email address is of type Email, not String so when I use the setToAddresses method in the SingleEmailMessage object it doesn't work because it expects an array of String. How can I cast the User.Email field from type email to String so I can use it in the setToAddresses method?

 

Example Code:

 

 

User assignedUser = [select u.id,
			u.email   // This is of type Email, not String
			from User u
			where u.id = :c.OwnerId
			limit 1];						  
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] { assignedUser.Email });   // This is how I want to use it This won't work because Email object cannot be casted to a String

 

 

So I have a class that contains a bunch of methods for performing actions on cases (sending emails, verification etc). Now I have a bunch of private final variable at the top that I want to create getters for but when I try to return the  value from a method in the same class I get this error: 

Save error: Variable does not exist: this.MBI_ID

 

Now the variable is declared private but I am accessing it within the same class. For some reason it does not see it. I have tried to return with and without the "this" keyword and it still does not work. I hope I am not just having a complete n00b moment here but any help would be appreciated. I posted a snippet below. Thanks in advance!

 

 

public with sharing class CaseUtils {
   final String MBI_ID = '0013000000XXXXXXXXX';
   
   public static String getMbiAcctId()
   { return MBI_ID; } // Tried with and without "this" keyword
}
   

 

 

Hi All,

 

For some reason I cannot remember how to restrict what record types are allowed in the portal. How is this done?

Hey All,

 

I have a trigger set on a custom object called Feature_Setup__c. The details of what the object does isn't really relevant but the main purpose of the trigger is to send an email whenever one of these objects is created. I have a custom email template setup and I am setting the WhatId for the SingleEmailMessage to the Id of the Feature_Setup__c object. When I do this and then call the Messaging.SendEmail() method I get the following exception:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger New_Feature_Setup_Send_Email caused an unexpected exception, contact your administrator: New_Feature_Setup_Send_Email: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: []: Trigger.New_Feature_Setup_Send_Email: line 46, column 17

 

The exception is saying that WhatId is not available for sending emails to UserIds.  I am not using the WhatId to send to a User it is set to the Id of my custom object. Anyone have any ideas on what this exception could mean? I'm at a loss.

Hi guys,

 

In SOQL, you can do like [SELECT Id, Name FROM Account ORDER BY Name LIMIT 1].

I was wondering what is the sequence of 'ORDER BY' and 'LIMIT 1', does it do 'ORDER BY' or do 'LIMIT 1' firstly?

Hi All,

 

I am trying to create a trigger on the CaseSolution object in SF. I am using the Force.com IDE plugin for eclipse. When I go to create a new trigger, CaseSolution is not in the list of available objects. I ran updates for the IDE to make sure there were no updates from SF and there were none. Is there a reason that I can't create a trigger on this object? Has anyone else ran into this before?

Hi All,

 

I am displaying History Related lists in Visualforce using the below code:

 

 

<apex:dataTable value="{!Object.histories}" var="history" rowClasses="odd,even" cellspacing="15" width="100%">
            <apex:column >
                <apex:facet name="header"></apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">
                <apex:param value="{!history.createddate}" />
                </apex:outputText>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Field</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <b> <apex:outputText value="{!history.field}"/></b>
                </apex:column>
            <apex:column >
                <apex:facet name="header">Editied By</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.createdby.name}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Old Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.oldvalue}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">New Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.newvalue}"/>
            </apex:column>
        </apex:datatable>

 

 

The history table is appearing in the ascending order(ie, "Created" is coming first, followed by the other field trackings).

 

But I need to display descendingly (by Created Date).

 

Any Suggestions?

 

Thanks

Bhuvana

  • February 09, 2011
  • Like
  • 0

Linking a VF page to a custom button on the Case page seems like an easy task. I create a new custom button, created multiple VF pages to link the button to but when I choose "Visualforce Page" for the button's Content Source field none of my vf pages appear in the drop down. I have made sure that the pages are available to everyone (In the security section for your VF page). Is there something that I'm missing? Sorry if this is a really dumb issue but I know I must be overlooking something really basic.

 

 

Hi,

 

I have been struggling with this all day. I'm just trying to get the value that was selected in a SelectList, and use it to do some DML stuff. I don't need to do an ajax request and print back to the screen (that seems to be what all of the code snippets out there are doing).

 

Here's the VF page:

 

<apex:page controller="SelectPricebookController" action="{!pageLoad}" showHeader="false" sidebar="false" title="Select Price List">
    <div class="opportunityTab" style="margin:15px;">
        <apex:form id="TheForm">
        <apex:sectionHeader title="Opportunity" subtitle="Select Price List"/>
        <div class="bDescription"></div>
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Price Book" for="ddlPriceBooks"/>
                    <apex:selectList id="ddlPriceList" size="1" multiselect="false" value="{!priceList}" title="Select a Price List">
                    	<apex:selectOptions value="{!lists}"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Select" action="{!savePriceList}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock> 
        </apex:form>
    </div>
</apex:page>

 

 

and here's the controller:

 

public with sharing class SelectPricebookController {


    private Opportunity opp;
    private Account acc;
    private Boolean isDirect = true;
    private String[] optionsToAdd;

    public String pList;
    
    
    public String getPriceList() {
        return pList;
    }

   public void setPriceList(String p) {
       System.Debug('================================== Set priceList: ' + p);
        this.pList = p;
    }
    
    public PageReference pageLoad(){
        //Get the Opportunity based on the query param
        String OppID;
        if (ApexPages.currentPage().getParameters().get('OppID') != null){
            OppID = ApexPages.currentPage().getParameters().get('OppID');
            
            opp = [Select Purchase_Channel_Account__c, Name, AccountId, Price_List__c from Opportunity where ID = :OppID Limit 1];
            
            //Gets the correct account. If the Purchase Channel account is null,
            //it will get the primary account.
            //If not, it will get Purchase Channel Account
            if (opp.Purchase_Channel_Account__c != null){
                acc = [Select NAME, Available_Direct_Price_Lists__c, Available_Channel_Price_Lists__c from Account where ID = :opp.Purchase_Channel_Account__c  Limit 1];
                isDirect = false;
            }
            else{
                acc = [Select NAME, Available_Direct_Price_Lists__c, Available_Channel_Price_Lists__c from Account where ID = :opp.AccountId  Limit 1];
            }

            System.debug('Opportunity ID======================================================> ' + opp.id);
            System.debug('Accout ID======================================================> ' + acc.id);
            
            //Gets the available price lists from the account
            String[] lists;
        
            if(isDirect){
                lists = acc.Available_Direct_Price_Lists__c.split(';');
            }
            else{
                lists = acc.Available_Channel_Price_Lists__c.split(';');
            }
                        
            //If there is only one option, just update the opp and redirect
            //Else, show the user a list to pick from
            if(lists.size() == 1){
                optionsToAdd = lists;
                return updateOpp(lists[0]);
            }
            else{
                optionsToAdd = lists;
                return null;
            }
        }
        else{
            //TODO: Handle Exception
            return null;
        }
    }
    
    public List<SelectOption> getLists(){
        List<SelectOption> options = new List<SelectOption>();
        
        for (Integer i = 0; i < optionsToAdd.size(); i++){
            System.debug('Options======================================================> ' + optionsToAdd[i]);
            options.add(new SelectOption(optionsToAdd[i],optionsToAdd[i]));
        }
        
        return options;
    }
    
    public PageReference savePriceList(){
        System.debug('============== pricelist: ' + pList);
        return updateOpp(pList);
    }
    
    private PageReference updateOpp(String p){
        opp.Price_List__c = p;
        System.debug('====================== Updated pricelist to: ' + p);
        update opp;
        
        PageReference pageRef = new PageReference('/' + opp.Id);
        pageRef.setRedirect(true);
        return pageRef;
    }
}

 

 

As you can see, I have a public string variable to hold the value, a getter and a setter. Then I try to use the variable in the savePriceList method. However, it's always null.

 

Thanks for the help!

Hi All,

 

I am new to VisualForce and I am still going through some testing with it to get more familiar. I am making a simple page where the user will enter a contact name and a list of all contacts that match the criteria will be displayed (in a dataTable). I setup my custom controller and wrote some VF markup for the page but I am getting the following error: 
Error: Could not resolve the entity from <apex:inputField> value binding '{!accountName}'. inputField can only be used with SObject fields.

 

I'm not sure what this means. My sample code is below. Does anyone have any suggestions?

 

 

Custom Controller

 

public class CardholderVfController {
    private String accountName;
    private List<String> accountList;
    private String contactName;
    private List<String> contactList;
    private final Case c;  
    
    //public CardholderVfController(ApexPages.StandardController stdController)
    //{
        //this.c = (Case)stdController.getRecord();
        //accountList = new List<String>(new String[] {'Test1', 'Test2'});
    //}
    
    public List<String> getAccounts()
    {
        accountList = new List<String>(new String[] {'TestAccountText1', 'TestAccountText2'});
        return this.accountList;
    }   
    
    public List<String> getContacts()
    {
        return this.contactList;
    }
    
    public void setAccountName(String s)
    {
        accountName = s;
    }
    
    public String getAccountName()
    {
        return this.accountName;
    }
    
    

}

 Page Markup

 

<apex:page controller="CardholderVfController">
<apex:form >
    <apex:pageBlock > 
    <apex:pageBlockSection >
        <apex:inputField id="accountNameField" value="{!accountName}"/>
        <apex:commandButton id="findAccount" title="Search"/>
    </apex:pageBlockSection>
    <apex:pageBlockSection >
            <apex:dataTable align="center" value="{!accounts}" var="a" >
                <apex:column value="{!a}"/>
            </apex:dataTable> 
    </apex:pageBlockSection>            
    </apex:pageBlock>
    {!accounts[0]}
</apex:form>
</apex:page>

 

 

 

Hi all,

 

I was doing some research to try and find the best (In this case "best" means easiest to read) way to provide an error message to a user . I have a trigger where I want to display a clear error message to the user if a defined maximum has been reached. When you throw an exception a long very confusing looking error message is displayed to the user detailing the trigger name, line number of the error etc. I really only want to display the exception's message, not all of the other details. Is there any way to do this? If not, what are other methods of informing the user that an error has occurred? Is there any way to call a message box from a trigger? I know I can use java script when the action is tied to a button to display a message box but this is a trigger, not a class. 

Hi All,

 

I am trying to use the email field under the User object to send an outgoing single email message. The problem I am having is that when I query for the email address in the User table the email address is of type Email, not String so when I use the setToAddresses method in the SingleEmailMessage object it doesn't work because it expects an array of String. How can I cast the User.Email field from type email to String so I can use it in the setToAddresses method?

 

Example Code:

 

 

User assignedUser = [select u.id,
			u.email   // This is of type Email, not String
			from User u
			where u.id = :c.OwnerId
			limit 1];						  
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] { assignedUser.Email });   // This is how I want to use it This won't work because Email object cannot be casted to a String