• Adriana Reyes 7
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
I created a custom action button that opens a visualforce page. I added it to my page layout, and when I see the record in Lightning, I can see the button and it does what I need it to, but when I go to the app, I don't see that button. Is there something that I am missing?

Thanks!
public class retrieveInvoice {
    private final Service_Call__c sc;
    
    public retrieveInvoice(ApexPages.StandardController stdController) {
        this.sc = (Service_Call__c)stdController.getRecord();
    }
    
    public List<Invoice_Detail__c> detailList {get;set;}
    public List<String> detailNames {get;set;}
    
    public void getInvoices() {
        detailList = [Select Id, Name from Invoice_Detail__c where Invoice__c = :sc.Invoice__c];

            for (Integer i=0; i<detailList.size(); i++) {
                detailNames.add(detailList.Name);
            }  
    }
So what I'm trying to do is loop through the Invoice Details list and save the name of each one in the list of strings. Then I would do that for other fields as well. For example, I would like to do one for description. The idea is to eventually create a table in a visualforce page, and each list of strings would be a column. My use case requires them to be saved as strings. Otherwise I would just create a table of Invoice Details.

Right now I'm getting this error: "Variable does not exist: Name" on the "detailNames.add(detailList.Name);" line. Can anyone point me in the right direction on how I can achieve this? Thank you!
 
List<String> myList = new List<String>();
myList.add('a');

I'm just playing arround with lists and it seems basic, but I keep getting errors. What am I doing wrong? I literally just copied and pasted, and got the error. I get both errors on the second line:
- Extra ')', at 'a'.
- Invalid constructor name: myList.add
I'm trying to write a test class for a controller with an extension, but I'm not really sure where to start. I've looked at the SF documentation, but I'm not understanding. Can anyone help me with this? Thanks!
 
public class selectWarehouse {
    private final Purchase_Requisition__c pr;
    
    public string selectedWarehouse{get;set;}
    
    public selectWarehouse(ApexPages.StandardController stdController) {
        this.pr = (Purchase_Requisition__c)stdController.getRecord();
    }
    
    public list<SelectOption> getWarehousenames() {
        List<SelectOption> options = new List<SelectOption>();
        for (Warehouse__c w : [select name from Warehouse__c order by name desc limit 100])
        {
            options.add(new SelectOption(w.name, w.name));
        }
        return options;
    } 
    
    public PageReference saveWarehouse(){
        pr.Warehouse_Text__c = selectedWarehouse;
        update pr;
        return new PageReference('/'+pr.Id);
    }
}

 
So I have an object called Purchase Requisition that has a button that leads the user to a pop up visualforce page where they select a Warehouse from a picklist which is another custom object. The picklist is generated by all of the records in the Warehouse object. I had to do this because users don't have access to Warehouse due to the cost of licensing. I want whatever their selection is on that window and then hit save, to then save the warehouse name as a text field on the purchase requisition records that they started with. I'm not really sure how to go about that. Here is the VF page and controller that I have built so far. Any help is appreciated!
 
public class selectWarehouse {
    private final Purchase_Requisition__c pr;
    
    public selectWarehouse(ApexPages.StandardController stdController) {
        this.pr = (Purchase_Requisition__c)stdController.getRecord();
    }
    public string selectedWarehouse{get;set;}
    
    public list<SelectOption> getWarehousenames() {
        List<SelectOption> options = new List<SelectOption>();
        for (Warehouse__c w : [select name from Warehouse__c order by name desc limit 100])
        {
            options.add(new SelectOption(w.name, w.name));
        }
        return options;
    }
}
 
<apex:page lightningStylesheets="true" standardController="Purchase_Requisition__c" extensions="selectWarehouse" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Select A Warehouse">
            <apex:outputLabel value="Warehouse "/>
            <apex:selectList size="1">
                <apex:selectOptions value="{!Warehousenames}">
                </apex:selectOptions>
            </apex:selectList>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page

 
I created a custom action button that opens a visualforce page. I added it to my page layout, and when I see the record in Lightning, I can see the button and it does what I need it to, but when I go to the app, I don't see that button. Is there something that I am missing?

Thanks!
public class retrieveInvoice {
    private final Service_Call__c sc;
    
    public retrieveInvoice(ApexPages.StandardController stdController) {
        this.sc = (Service_Call__c)stdController.getRecord();
    }
    
    public List<Invoice_Detail__c> detailList {get;set;}
    public List<String> detailNames {get;set;}
    
    public void getInvoices() {
        detailList = [Select Id, Name from Invoice_Detail__c where Invoice__c = :sc.Invoice__c];

            for (Integer i=0; i<detailList.size(); i++) {
                detailNames.add(detailList.Name);
            }  
    }
So what I'm trying to do is loop through the Invoice Details list and save the name of each one in the list of strings. Then I would do that for other fields as well. For example, I would like to do one for description. The idea is to eventually create a table in a visualforce page, and each list of strings would be a column. My use case requires them to be saved as strings. Otherwise I would just create a table of Invoice Details.

Right now I'm getting this error: "Variable does not exist: Name" on the "detailNames.add(detailList.Name);" line. Can anyone point me in the right direction on how I can achieve this? Thank you!
 
List<String> myList = new List<String>();
myList.add('a');

I'm just playing arround with lists and it seems basic, but I keep getting errors. What am I doing wrong? I literally just copied and pasted, and got the error. I get both errors on the second line:
- Extra ')', at 'a'.
- Invalid constructor name: myList.add