• adrissel
  • NEWBIE
  • 184 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 42
    Questions
  • 74
    Replies
Hey all, I need to pass the set value of one of my selectList options back to a specific method in my controller.  It isn't working and I can't find out why.  Can someone glance at the code below and tell me what I'm missing here?

Controller
public class LogACaseController{

    public Boolean aso {get;set;}
    public Boolean cd {get;set;}
    public Boolean ss {get;set;}
    private Id userId {get;set;}
    public String baseUrl {get;set;}
    public String selection {get;set;}
    public List<String> products = new List<String>();    
        
    /*
     * Get ContactId of logged-in User
     */
    
    public PageReference getUserInfo(){   
    
        userId = UserInfo.getUserId();
        getPermSets(userId);
        getBaseUrl();
        return null;
    }
    
    /*
     * Get permission sets of logged-in User
     */
    
    public void getPermSets(Id userId){
    
        Id asoPsId = [SELECT Id FROM PermissionSet WHERE Name = 'ASO_Community' LIMIT 1].Id;
        Id ssPsId = [SELECT Id FROM PermissionSet WHERE Name = 'SS_Community' LIMIT 1].Id;
        Id cdPsId = [SELECT Id FROM PermissionSet WHERE Name = 'CD_Community' LIMIT 1].Id;
        List<PermissionSetAssignment> asoAssigneeIds = new List<PermissionSetAssignment>([SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId =: asoPsId]);
        List<PermissionSetAssignment> ssAssigneeIds = new List<PermissionSetAssignment>([SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId =: ssPsId]);
        List<PermissionSetAssignment> cdAssigneeIds = new List<PermissionSetAssignment>([SELECT AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId =: cdPsId]);
        
        for(PermissionSetAssignment asoId : asoAssigneeIds){
        
            if(asoId.AssigneeId == userId){
            
                aso = true;
            }
        }  
         
        for(PermissionSetAssignment ssId : ssAssigneeIds){
        
            if(ssId.AssigneeId == userId){
            
                ss = true;
            }
        }   
        
        for(PermissionSetAssignment cdId : cdAssigneeIds){
        
            if(cdId.AssigneeId == userId){
            
                cd = true;
            }
        }   
    }
    
    /*
     * Get product options
     */
            
    public List<SelectOption> getOptions(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('none','--None--'));
        options.add(new SelectOption('aso','Advanced Sourcing Optimizer'));
        options.add(new SelectOption('cd','Contract Director'));
        options.add(new SelectOption('ss','eProcurement/SelectSite'));
        return options;
    }
        
    public List<String> getProducts() {
        return products;
    }
    
    public void setProducts(List<String> products) {
        this.products = products;
    }
    
    /*
     * Get pagereference based on user product selection
     */
     
    public PageReference getCasePage(){
     
        PageReference pr;         
        RecordType asoRt = [SELECT Id FROM RecordType WHERE DeveloperName = 'ASO' LIMIT 1];
        RecordType cdRt = [SELECT Id FROM RecordType WHERE DeveloperName = 'Contract_Director' LIMIT 1];
        RecordType ssRt = [SELECT Id FROM RecordType WHERE DeveloperName = 'SelectSite_Support' LIMIT 1];
         
        if(aso == true){
        
            pr = new PageReference(baseUrl+'/support/500/e?retURL=%2Fsupport%2F500%2Fo&RecordType='+asoRt.Id+'&ent=Case');
        }
         
        else if(cd == true){
        
            pr = new PageReference(baseUrl+'/support/500/e?retURL=%2Fsupport%2F500%2Fo&RecordType='+cdRt.Id+'&ent=Case');
        }
        
        else if(ss == true){
        
            pr = new PageReference(baseUrl+'/support/500/e?retURL=%2Fsupport%2F500%2Fo&RecordType='+ssRt.Id+'&ent=Case');
        }
        
        return pr;
    }
    
    /*
     * Get baseUrl
     */
     
     public String getBaseUrl(){
     
         baseUrl = Url.getSalesforceBaseUrl().toExternalForm();
         
         return baseUrl;
     }
}

VF Page
 
<apex:page controller="LogACaseController" tabStyle="Log_A_Case__tab" action="{!getUserInfo}">
  <head>
      <script>
          function getCasePage(){
              var selection = document.getElementById("{!$component.form.product}").value;
              alert(selection);
              getCasePageFunction(selection);
          }
      </script>
  </head>
  <body>
      <apex:form id="form">
          <apex:actionFunction action="{!getCasePage}" id="getCasePage" name="getCasePageFunction">
              <apex:param assignTo="{!selection}" id="selection" name="selection" value=""/>
          </apex:actionFunction>
          <br/><span style="font-size: 14px;font-weight: bold;">Select a product:</span>&nbsp;&nbsp;
          <apex:selectList id="product" value="{!products}" multiselect="false" size="1" onchange="return getCasePage();">
              <apex:selectOptions value="{!options}"></apex:selectOptions>
          </apex:selectList>
      </apex:form>
  </body>
</apex:page>

Thanks ahead of time!
Hey all,

I want to implement a component in the sidebar of my home page for searching Contacts and Accounts.  I have a VF page with an associated controller that I want to use for this component (the search functionality is built in there).  However, I am experiencing an issue that I can't see how to fix.  When the search criteria is entered and the search button clicked, the component in the sidebar is what is refreshed with the resulting data, not the main page. 

How can I cause a sidebar component to refresh and display data on the main page?

Thanks!

Adam
Hey all,

I want to implement a component in the sidebar of my home page for searching Contacts and Accounts.  I have a VF page with an associated controller that I want to use for this component (the search functionality is built in there).  However, I am experiencing an issue that I can't see how to fix.  When the search criteria is entered and the search button clicked, the component in the sidebar is what is refreshed with the resulting data, not the main page. 

How can I cause a sidebar component to refresh and display data on the main page?

Thanks!

Adam
Hey all.  I am trying to refine a search functionality I have developed.  I want the search string the user enters to search ALL FIELDS to return as many relevant results as possible.  However, I am expecting certain data to show that aren't.  For example, I have an account with the Account Name of "Worldwide Acme Holdings".  The user is entering the search string "acme".  There are lots of Contacts associated with that account.  However, the search results do not yield any of those contacts.  Here is my query:
 
allAccsCons = [FIND :searchString IN FIELDS RETURNING Contact(Name,Id,AccountId,Email,Phone,Account.Name),Account(Id,Name,Type,BillingCity,BillingState,Industry)];
It doesn't seem that the SOSL query is looking at the "Account.Name" value for the Contact sObject.  The account results themselves do contain the Account mentioned above.  But, I am wanting a contact list as well of all contacts who are part of that account. 

Am I doing something wrong here?  Technically the field with the Account Name label in SF is an Id/Lookup field.  Is that why?  Any viable workarounds?

Thanks!
 
Hey all,

I am writing a test class and need to know how to set the baseUrl based on the following method in my controller:
public String getBaseUrl(){
        
        vfUrl = Url.getSalesforceBaseUrl().toExternalForm();
        Integer iIndex = vfUrl.indexOf('.visual');
        instance = vfUrl.substring((iIndex-4),(iIndex));
        baseUrl = 'https://'+instance+'.salesforce.com';
        
        return baseUrl;
    }
This method is built to convert the VF page url it begins with into the simple instance URL.  However, when I run the following test class I get the error:

"System.StringException: Starting position out of bounds: -5"

Test Class:
@isTest
private class Five9ScreenPopTest{

    @isTest static void testFive9ScreenPop(){
    
        CreateUser cu = new CreateUser();        
        User u = cu.createUser();
        ApexPages.StandardController cont;
        
        System.RunAs(u){
        
            String ani = '8005551212';
            Test.setCurrentPage(pageRef);
            
            Five9ScreenPop f9sp = new Five9ScreenPop(cont);
            PageReference numCases = f9sp.NumCases();
        }
    }
}
NumCases() is a method within the Five9ScreenPop class.

How do I set the baseUrl for my testing here?  Do I need to pass a starting URL to the controller?  How do I do that?

Thanks!

 
Hey all,

I am trying to perform a SOQL query in my controller to pull all Contacts in my org that have no associated AccountId.  Somehow some of my users, without access to the API, were able to create orphaned Contacts (Contacts without an Account selected upon creation).  This is breaking some custom Apex/VF we have programmed because of various Exceptions including "de-reference null object", et al.

I tried searching the web for some answer to this, but couldn't come up with anything.  When I perform the SOQL query it returns no information.  As soon as I add an account to the Contact in question it pulls perfectly with the query.

Can anyone tell me if what I am trying to do is even possible?  Is there a restriction with SOQL that only allows Contacts to be pulled IF they have an Account associated with them?  Is there any viable workaround?

Thanks!

Adam
 
I have the following VF code:
<apex:page controller="Five9ScreenPop">
    <head></head>
    <body>
        <apex:form>
            <apex:commandLink name="link" action="{!NewCase}" />
        </apex:form>
    </body>
</apex:page>
Controller:
public with sharing class Five9ScreenPop{

    public PageReference NewCase(){     
               
        PageReference pr = new PageReference('http://www.google.com');        
        pr.setRedirect(true);        
        return pr;
    }
}
The SF documentation on <apex:commandLink> says "A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action." (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_commandLink.htm)

When I load my VF page nothing happens.  No redirect, no nothing. 

What am I doing wrong here?

Thanks!!
 
We are using Apex and VF for a Case Creation page for our customers on the community.  In the code we have the following, per Salesforce's documentation:
 
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
dmo.EmailHeader.triggerAutoResponseEmail = true;
dmo.EmailHeader.triggerOtherEmail = true;
dmo.EmailHeader.triggerUserEmail = true;
curCase.setOptions(dmo);
This works PERFECTLY as far as the case assignment rules go.  However, on most of the rules we have there are also automated notifications that are supposed to be sent immediately upon assignment to that queue/individual.  For some reason, only with cases filed via the VF page, these notifications aren't sent.  The cases are assigned properly, but no notifications.

These notifications are extremely important to our case-handling procedures here.  When I create test cases directly in Salesforce and use the assignment rules the notifications work perfectly.  Only cases file on the customer community prevent this.

Can anyone explain why this isn't working and help me with a fix?

Thanks!!!
 
I need to be able to reference the index of a certain value in Visualforce, not the label.  Here is an example:
<apex:pageBlockTable value="{!allData}" var="d" id="theTable">
	<apex:column >
		<apex:facet name="header">Contact Name</apex:facet>
		<apex:outputText value="{!d.Name}"/>
	</apex:column>
<apex:pageBlockTable

In the example above there is usually a label of the object for "Name" that would get pulled in.  However, I had to build a custom list in my controller which doesn't have labels for each index value.  I need something like:
<apex:pageBlockTable value="{!allData}" var="d" id="theTable">
	<apex:column >
		<apex:facet name="header">Contact Name</apex:facet>
		<apex:outputText value="{!d.[index#]}"/>
	</apex:column>
<apex:pageBlockTable

Nothing I try is working.  How can I just call the index place of the value in the list instead of calling it by a label?

Thanks!

 
I would like to pull the URL for the File Attachment in my Knowledge Article, is this possible? In my article type i created a data Type for File Attachment called TestImage, but unfortunately I'm unable to figure out to retrieve this URL.

I am implemententing a custom Visualforce page for Knowledge. Any assistance would be appreciated. Thanks