• adrissel
  • NEWBIE
  • 179 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!
I'm sorry, but I am having an amazingly difficult time doing what would seem to be an easy function in the Community Builder.  I am using the "Napili" template, which is supposed to support case filing.  However, when I am in the Builder, select the "Contact Support" page, click on the "Case Creation" element to the left, and enter "NewCase" into the "Signed-In User Case Action" box it gives me the following error:

User-added image

And here is a screenshot showing we have an action called "NewCase":

User-added image

Somebody please tell me that I am missing something super-simple here.

Thanks!

PS - Is it possible to customize which fields are included on the Case Creation page (i.e. can we use a form instead of a simple contact form)?
Hey all.  I am trying to write a custom trigger which requires information I have placed as parameters in the referring URL.  Here is the code:

Trigger
trigger AddActivity on Case (before insert) {

    List<Case> cases = Trigger.new;
    Case c = cases[0];    
    AddActivity aa = new AddActivity();
    Map<String,Id> urlInfo = aa.getUrlInfo();
    
    system.debug('-------------------> urlInfo: '+urlInfo);
}

Class
public class AddActivity{

    public Map<String,Id> getUrlInfo(){
    
        String origin = ApexPages.currentPage().getParameters().get('origin');
        Id accId = ApexPages.currentPage().getParameters().get('def_account_id');
        Map<String,Id> urlInfo = new Map<String,Id>{    
            'origin' => origin,
            'accId' => accId
        };
    
        return urlInfo;
    }
}

The result when saving a Case record is "Error: Invalid Data. Review all error messages below to correct your data. Apex trigger AddActivity caused an unexpected exception, contact your administrator: AddActivity: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Class.AddActivity.getUrlInfo: line 5, column 1".

With every debug I do and attempt to pull URL parameters using URL methods, Site methods, whatever...none of them produce what I need.  Here is an example of a URL I have:
https://cs24.salesforce.com/500/e?retURL=%2F500%2Fo&RecordType=01230000000n2BN&def_account_id=00130000003zgQYAAY&def_contact_id=003a000001mAJxpAAG&ent=Case&origin=Five9
I need to be able to pull the "query" portion of it and parse the data from there (everything after the ?).

Is there no way to do this with a Trigger?

Thanks!!

 
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,
There are two functions I am attempting to perform, the first of which is the desired and the second of which is the "I'll settle for it" option.

Is it possible to:

(1) Create a custom home page component (sidebar) of some sort that invokes and posts data to a VF page in the MAIN BODY of the screen (i.e. it doesn't render it in the sidebar itself.)?

(2) Create a custom home page component (sidebar) that simply causes the ENTIRE PAGE to refresh (not just the component in the sidebar)?

Here is the code for an example of #2:
<apex:page standardController="User" extensions="Five9ScreenPop">
    <script type="text/javascript">
        function redirect(){        
            window.top.location.href("https://c.cs24.visual.force.com/apex/Five9_Select_Pop?ANI=9999999999");            
            return false;
        }
    </script>
    <apex:form id="searchForm">
        <center><apex:commandButton value="Search Contacts & Accounts" action="redirect();"/></center>
    </apex:form>
</apex:page>
When this button is clicked the small little section of the home page component in the sidebar is what is redirected, not the entire page.

How can I accomplish this?

 
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!!
 
Hello,

I have the following code in my VF Email Template:
<apex:outputText rendered="{IF(!relatedTo.RecordTypeId = '012a00000018Ens')}">{!relatedTo.id}</apex:outputText>
The relatedTo type here is "Case".  The goal here is to have the VF Email Template send to an external Contact when an agent makes a new public comment on the Case.  The above format does absolutely nothing when I do verify merge field tests.

I have also tried the following:
<div style="{IF(!relatedTo.RecordTypeId = '012a00000018Ens')},'display:block;','display:none;'">{!relatedTo.id}</div>
Again, nothing.

I have read other articles that say to include an exclamation point in front of the "IF", but when I do that I get the following error:
Error: Incorrect parameter type for function 'not()'. Expected Boolean, received Text
I really need to get this to work asap. 

Any help?


 
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 have a visualforce page that I am using the <apex:detail> functionality on for the Case Object.  Everything displays very nicely, including the list of any emails sent to/from the case.  One problem, the Subject lines that are supposed to be linked to the actual email itself don't work.  Here is an example of what one looks like:

Email Related List

When I click on that link it does absolutely nothing.  When I hover over the link the following is displayed in the browser:
javascript:srcUp(%27%2Fss%2F02s190000004il2%3Fisdtp%3Dvw%27);
Whatever this link is it does not point to the case email itself.

Can someone help me with this?  I need our customers to have the ability to see the content of the emails associated with the case.

Thanks!!
 
I have classes that perform different functions based on what the path prefix is for the site the user is logged into.  I am trying to write a test class to cover all the code for these various scenarios.  But, no matter what I try I cannot SET the pathPrefix to a certain value to allow the test class to cover all the code.  

Can someone tell me if this is possible and if so, how to do it?

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 have a customer-facing community.  Each page of the community is made up of custom VF code.  I would like to add a tab on my home page for "Ideas" that, when clicked, basically has the exact same appearance and functionality of the default "Ideas" tab in Salesforce.  Here is a screenshot of what I want to see:

User-added image

I want the same functionality...promote...demote...comment...etc.

Is this possible?  Can I basically duplicate this functionality in VF?

Thanks,

Adam
I am trying to create a VF page that is essentially identical to the standard Salesforce Ideas page (Zones, tabs, et al).  To get started I am trying to follow the instructions for this laid out here: http://www.salesforce.com/us/developer/docs/pages/index.htm (search for Ideas).

There the following VF code is listed:
<!-- page named listPage -->
<apex:page standardController="Idea" extensions="MyIdeaListExtension" recordSetVar="ideaSetVar">
    <apex:pageBlock >
        <ideas:listOutputLink sort="recent" page="listPage">Recent Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="top" page="listPage">Top Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="popular" page="listPage">Popular Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="comments" page="listPage">Recent Comments
        </ideas:listOutputLink>
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:dataList value="{!modifiedIdeas}" var="ideadata">
            <ideas:detailoutputlink ideaId="{!ideadata.id}" page="viewPage">
             {!ideadata.title}</ideas:detailoutputlink>
        </apex:dataList>
    </apex:pageBlock>
</apex:page>

When I attempt to use this I get the error:
Error: Unknown page listPage referenced by attribute page in <ideas:listOutputLink> in listPage at line 3 column 61

I am totally confused!!!  Do I need a separate VF page named "listPage" (I tried a blank page with that name and it still threw the same error).

(1) Can I even create a VF page that is a duplicate (or as close as possible) to the Standard Ideas page?
(2) How can I do that?

Thanks!!!
I am trying to create a VF page that is essentially identical to the standard Salesforce Ideas page (Zones, tabs, et al).  To get started I am trying to follow the instructions for this laid out here: http://www.salesforce.com/us/developer/docs/pages/index.htm (search for Ideas).

There the following VF code is listed:
<!-- page named listPage -->
<apex:page standardController="Idea" extensions="MyIdeaListExtension" recordSetVar="ideaSetVar">
    <apex:pageBlock >
        <ideas:listOutputLink sort="recent" page="listPage">Recent Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="top" page="listPage">Top Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="popular" page="listPage">Popular Ideas
        </ideas:listOutputLink>
        | 
        <ideas:listOutputLink sort="comments" page="listPage">Recent Comments
        </ideas:listOutputLink>
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:dataList value="{!modifiedIdeas}" var="ideadata">
            <ideas:detailoutputlink ideaId="{!ideadata.id}" page="viewPage">
             {!ideadata.title}</ideas:detailoutputlink>
        </apex:dataList>
    </apex:pageBlock>
</apex:page>
When I attempt to use this I get the error:
Error: Unknown page listPage referenced by attribute page in <ideas:listOutputLink> in listPage at line 3 column 61
I am totally confused!!!  Do I need a separate VF page named "listPage" (I tried a blank page with that name and it still threw the same error).

(1) Can I even create a VF page that is a duplicate (or as close as possible) to the Standard Ideas page?
(2) How can I do that?

Thanks!!!

 
I have a VF page I created for users to quickly create common Cases.  It has a controller for the actual Case-creation portion, et al.  I am trying to write a test class to get code coverage and for some reason it is just failing over and over.  No matter what modifications I have attempted I get the exact same error.  Here are the relevant code snippets with my question following:

VF Page:
<apex:page standardcontroller="Case" extensions="SIMSQuickCreate">

    <script type="text/javascript">

        function createCase(cancel) {

            var supplier = document.getElementById('{!$Component.form.block.section1.supplierInput}').value;
            var acc = document.getElementById('{!$Component.form.block.section1.accInput}').value;
            var conPerson = document.getElementById('{!$Component.form.block.section1.conPersonInput}').value;
            var con = document.getElementById('{!$Component.form.block.section1.conInput}').value;
            var conPersonPhone = document.getElementById('{!$Component.form.block.section1.conPersonPhoneInput}').value;
            var conPersonEmail = document.getElementById('{!$Component.form.block.section1.conPersonEmailInput}').value;
            var sub = document.getElementById('{!$Component.form.block.section2.subInput}').value;
            var descr = document.getElementById('{!$Component.form.block.section2.descrInput}').value;
            var cat = document.getElementById('{!$Component.form.block.section3.catInput}').value;
            var subCat = document.getElementById('{!$Component.form.block.section3.subCatInput}').value;
            
            if(cancel == 1) {
            
                cancelFunction();
            }

            else {
            
                if (supplier.toUpperCase() != 'UNKNOWN' && (conPerson == '' || conPersonPhone == '' || conPersonEmail == '')) {
                
                    alert("Known Suppliers require a Contact Person, Contact Person Phone, and Contact Person Email.  If the Supplier is unknown please enter 'Unknown'.");
                }
                
                else {
                
                    createFunction(supplier,acc,conPerson,con,conPersonPhone,conPersonEmail,sub,descr,cat,subCat);
                }
            }
            
            return false;
        }

    </script>
    <apex:form id="form">
    <apex:actionFunction name="createFunction" action="{!createCase}" rerender="form">    
        <apex:param id="supplier" assignTo="{!supplier}" name="supplier" value="" />  
        <apex:param id="acc" assignTo="{!acc}" name="acc" value="" />
        <apex:param id="conPerson" assignTo="{!conPerson}" name="conPerson" value="" />
        <apex:param id="con" assignTo="{!con}" name="con" value="" />
        <apex:param id="conPersonPhone" assignTo="{!conPersonPhone}" name="conPersonPhone" value="" />
        <apex:param id="conPersonEmail" assignTo="{!conPersonEmail}" name="conPersonEmail" value="" />
        <apex:param id="sub" assignTo="{!sub}" name="sub" value="" />
        <apex:param id="descr" assignTo="{!descr}" name="descr" value="" />
        <apex:param id="cat" assignTo="{!cat}" name="cat" value="" />
        <apex:param id="subCat" assignTo="{!subCat}" name="subCat" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="cancelFunction" action="{!cancelCreate}" immediate="true"/>
    <apex:pageBlock id="block" title="SIMS Quick Create" mode="edit">
        <center><apex:commandButton value="Create" onclick="return createCase();"/><apex:commandButton value="Cancel" onclick="return createCase(1);"/></center>
        <apex:pageBlockSection id="section1" title="Supplier Information" columns="2">
            <apex:inputField id="supplierInput" value="{!Case.Supplier__c}"/>
            <apex:inputField id="accInput" value="{!Case.AccountId}" required="true"/>
            <apex:inputField id="conPersonInput" value="{!Case.Contact_Person__c}"/>
            <apex:inputField id="conInput" value="{!Case.ContactId}" required="true"/>
            <apex:inputField id="conPersonPhoneInput" value="{!Case.Contact_Person_Phone__c}"/>
            <apex:pageBlockSectionItem />
            <apex:inputField id="conPersonEmailInput" value="{!Case.Contact_Person_Email__c}"/>
            <apex:pageBlockSectionItem />
        </apex:pageBlockSection>
        <apex:pageBlockSection id="section2" title="Email-To-Case Information">
            <apex:inputField id="subInput" value="{!Case.Subject}" required="true"/>
            <apex:pageBlockSectionItem />
            <apex:inputField id="descrInput" value="{!Case.Description}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection id="section3" title="SIMS Detail">
            <apex:inputField id="catInput" value="{!Case.SIMS_Category__c}" required="true"/>
            <apex:pageBlockSectionItem />
            <apex:inputField id="subCatInput" value="{!Case.SIMS_Sub_category__c}" required="true"/>
        </apex:pageBlockSection>
        <center><apex:commandButton value="Create" onclick="return createCase();"/><apex:commandButton value="Cancel" onclick="return createCase(1);"/></center>
    </apex:pageBlock> 
    </apex:form>
</apex:page>

Controller:
public with sharing class SIMSQuickCreate{

    Apexpages.StandardController setCon;
    
    // SET VARIABLES
   
    public String supplier {get; set;}
    public String acc {get; set;}
    public String conPerson {get; set;}
    public String con {get; set;}
    public String conPersonPhone {get; set;}
    public String conPersonEmail {get; set;}
    public String sub {get; set;}
    public String descr {get; set;}
    public String cat {get; set;}
    public String subCat {get; set;}
    

    // CREATE NEW CASE VARIABLE    
    
    public Case c = new Case();
    
    
    // INSTANTIATE CONTROLLER
   
    public SIMSQuickCreate(Apexpages.StandardController controller) {

        setCon = controller;
    }
    
    public Pagereference createCase(){
        
        system.debug('--------------------------------------------------------------> Here is the value: '+acc+'  '+con);
        
        
        // GET ACCOUNTID FROM ACCOUNT NAME ENTERED
        
        List<Account> accList = new List<Account>{[SELECT Name,Id FROM Account WHERE Name =: acc]};
        
        Id accId = accList[0].Id;
        
        
        // GET CONTACTID FROM CONTACT NAME ENTERED
    
        List<Contact> conList = new List<Contact>{[SELECT Id FROM Contact WHERE Name =: con]};
        
        Id conId = conList[0].Id;
        
        
        // SET DEFAULT FIELD VALUES
        
        c.Status = 'Active in Support';
        c.Origin = 'Phone';
        c.Site_Outage__c = 'No';
        c.Severity_Level__c = 'Severity 4';
        c.Plan_Sent__c = date.today();
        c.Date_Issue_Originated__c = date.today();
        c.Product__c = 'Total Supplier Manager';
        c.SIMS_Root__c = 'Question/Training';
        c.Reported_by__c = 'No';
        
    
        // SET FIELD VALUES FROM USER INPUT
        
        c.AccountId = accId;        
        c.ContactId = conId;    
        c.Supplier__c = supplier;        
        c.Contact_Person__c = conPerson;        
        c.Contact_Person_Phone__c = conPersonPhone;        
        c.Contact_Person_Email__c = conPersonEmail;        
        c.Subject = sub;        
        c.Description = descr;        
        c.SIMS_Category__c = cat;        
        c.SIMS_Sub_category__c = subCat;
                
                
        // INSERT NEWLY CREATED CASE
        
        insert c;
        
        
        // SET CASE ID FOR REDIRECT URL
        
        Id caseId = c.Id;        
        
        Pagereference casePage = new Pagereference('/'+caseId);
        casePage.setRedirect(true);
        
        return casePage;
    }
    
    public Pagereference cancelCreate(){
    
        return new Pagereference('/'+Case.getSObjectType().getDescribe().getKeyPrefix()+'?fcf='+ApexPages.currentPage().getParameters().get('retUrl'));
    }
}


Test Class:
@isTest
private class SIMSQuickCreateTest {
  
    static testMethod void testSIMSQuickCreate() {
                
        // GET System Administrator PROFILE FOR TESTING
        
        Profile pro = [SELECT Id FROM Profile WHERE Name = 'System Administrator' LIMIT 1];
    
        PageReference pageRef = Page.SIMS_Quick_Create;
        
        List<Case> caseList = new List<Case>();
        
        
        // CREATE TEST USER FOR TESTING
        
        User u = new User(
            alias = 'u2', 
            email = 'test@test.com',
            emailencodingkey = 'UTF-8',
            FirstName = 'test',
            lastname='U',
            languagelocalekey = 'en_US',
            localesidkey = 'en_US',
            profileid = pro.Id,
            timezonesidkey = 'America/Los_Angeles',
            CommunityNickname = 'u2',
            isActive = true,
            username = 'testSciquest@test.com'
        );
        
        insert u;
        
                
        System.RunAs(u){
            
            Apexpages.StandardController controller;
            
            SIMSQuickCreate sqc = new SIMSQuickCreate(controller);
        
            String acc = 'Generic Supplier';
            String con = 'Supplier Issue';         

            sqc.createCase();
            sqc.cancelCreate();
        }
    }
}

The following error is what is returned in the Apex Test Execution:
Error Message:	System.QueryException: List has no rows for assignment to SObject
Stack Trace:	
Class.SIMSQuickCreate.createCase: line 38, column 1
Class.SIMSQuickCreateTest.testSIMSQuickCreate: line 58, column 1

Long story short, despite the fact that the "acc" and "con" variables are being passed correctly in the test class to the "createCase()" function, the query I am pulling for the Account in the controller isn't finding any data.  (It returns data just fine when the EXACT SAME data is entered on the actual VF page).

Please help.

Thanks!!
 
I am getting the below error when trying to delete records using dataloader.io.  The file is only a list of EmailMessage Ids.  Any ideas what this could be?

expected name start and not < (position: TEXT seen ...<id xsi:nil="true"/><success>false</<... @1:32972)
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!!!
 
My question is of a specific and general nature.  First the specific aspect.  I have the following code in my controller:

public class ListVisableCategories {

    // INSTANTIATE CONTROLLER
    
    public ListVisableCategories(){}
    

    // SET VARIABLES
    
    public Set<String> setRootCat{get;set;}
    public String prefix = Site.getPathPrefix();
    
    
    // DESCRIBE VISABLE CATEGORIES
    
    public static List<String> describeVisibleCategories(Map<String, String> mLabelCat, Map<String, List<String>> mCatStructure, Map<String, String> mParentCategory){
    
        if (prefix == '/xyz') {
    
            Set<String> setRootCat = new Set<String>{'Buyer_Articles'};
        }
    
        else if (prefix == '/abc') {
    
            Set<String> setRootCat = new Set<String>{'All'};
        }

        List<String> listVisableCategories = new List<String>();
        
         ........
            
            // IF APPLICABLE, GATHER ALL CHILD CATEGORIES
            
            if(setRootCat.contains(dc.getName())){
            
                for(DataCategory dcChild : dc.getChildCategories()){ 
                
                    listVisableCategories.add(dcChild.getName());
                }
            }
            
            else{
    
                listVisableCategories.add(dc.getName());
            }
        }
    
        return listVisableCategories;
    }

}

Ignoring other aspects of the code that may be missing (I didn't paste the entire controller) why in the world is it giving me a Compile Error for both the "setRootCat" and "prefix" variables saying that they "don't exist"?  Both variables are declared public.  Shouldn't I be able to access them later in the controller?

The general aspect of my question is why Apex doesn't allow simple usage of a variable across various functions in a class.  PHP, Java, Javascript...they all allow this, but declaring and using variables in various Apex methods in a class seems very cumbersome.  Maybe I'm missing something simple?

Thanks ahead of time!
I have placed a custom button on a Case List view.  The button, when clicked, needs to validate whether any case records were actually selected.  That part is done simply with a Javascript OnClick button with the following code:

{!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} 

var selected = {!GETRECORDIDS($ObjectType.Case)}; 

if (selected[0] == null) { 

    alert("Please select at least one Case.")
} 

else {

     window.location = 'apex/MyPage';
}

The problem is that when validation passes (i.e. it goes to the MyPage visualforce page) the selected records aren't passed along.  Here is my VF page thus far:

<apex:page standardController="Case" recordSetVar="cases">
   <apex:form >
       <apex:pageBlock title="MyPage" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="MyButton"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputCheckBox value="{!case.test__c}" selected="true" required="true"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!case.test2__c}" showDatePicker="true" required="true"/>
                <apex:inputField value="{!case.test3__c}" showDatePicker="true" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Cases">
                <apex:pageBlockTable value="{!selected}" var="case">
                    <apex:column value="{!case.casenumber}"/>
                    <apex:column value="{!case.subject}"/>
                    <apex:column value="{!case.status}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>   
</apex:page>
The goal is to have the custom button on the List view validate whether records are checked, then when validation passes have those records displayed in the block table on the VF page.  I can get one or the other to work, but not both at the same time.  If I change the button to go directly to the VF page, the selected records appear perfectly, but no validation occurs (i.e. it allows redirect when no records are selected).  If I have the button set to the Javascript code it validates the records but doesn't display the selected records on the VF page.

I have searched the internet for hours on everything I could think of and couldn't find anything to help me.  

Can anyone out there offer a solution?

THANKS!!
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