• Ezmo
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi all,

 

Just a quick one which I'm sure is really easy but I've been wracking my brains for a few hours on this one. 

 

I want to do an if function that would read along the lines of "If string x starts with string y".

 

Any help would be great!

 

Many thanks

 

Eran

  • November 20, 2012
  • Like
  • 0

Hi there,

 

I was just wondering if someone knows a quick way of doing this.

 

I've built a custom component that I want to put into some of my visualforce pages. This component has a list in it, when I click on a value I want it to be transferred into a field on the page. I've got it working using <apex:param> and an outputlink, however this requires the page to refresh which then clears any data already inputted into any other fields, which I don't want to happen.

 

Any ideas would be fab.

 

Thanks

 

Ezmo

  • December 01, 2011
  • Like
  • 0

Morning,

 

I've been having a bit of an issue when trying to deploy a trigger and it's test from a sandbox to production. I've pasted the error and code below, any help or ideas would be much appreciated as this has got me stumped.

 

Failure Message: "System.QueryException: List has no rows for assignment to SObject", Failure Stack Trace: "Class.TestTriggers.myUnitTest: line 13, column 13 External entry point"

 

trigger stockControl on Transfer__c (after insert) {
    
    for (Transfer__c t : Trigger.new){
        if (t.Transfer_Type__c == 'inbound'){
            
            Decimal existingQuantity = 0;
            
            Stock_Level__c s = new Stock_Level__c();
            try{
            s = [SELECT Quantity__c 
                                FROM Stock_Level__c 
                                WHERE   Storage_Area__c = :t.Storage_Area__c AND 
                                        Resource__c = :t.Resource__c];
                                        
            existingQuantity = s.Quantity__c;                           
                      
            }
            catch(exception e){           
            }
            s.Resource__c = t.Resource__c;
            s.Storage_Area__c = t.Storage_Area__c;  
            s.Quantity__c = t.Quantity__c + existingQuantity;
            upsert s;
        }
    }
}

 

 

@isTest
private class TestTriggers {

    static testMethod void myUnitTest() {
        
        Transfer__c t = new Transfer__c();
        t.Quantity__c = 100000;
        t.Transfer_type__c = 'inbound'; 

        insert t; 
        
        Stock_Level__c s = new Stock_Level__c();
        s = [SELECT id FROM Stock_Level__c WHERE Quantity__c = 100000];
        
        id i = s.id;
        
        insert t;
        
        s = [SELECT id FROM Stock_Level__c WHERE id = :i];
        
        
        System.assert(s.Quantity__c == 200000);
        
    }
}

 

Thanks in advance.

  • September 26, 2011
  • Like
  • 0

Hi,

 

I've created a dynamic table which allows you to add rows which contain custom fields. Once the save button is clicked all the rows are inserted at once.

 

I'm wanting to add a 'delete row' button on each row.

 

My problem is that I need to be able to pass the row index to the remove method in the apex code.

 

Does anyone have any examples of this?

 

Many thanks in advance

 

Ezmo

  • June 27, 2011
  • Like
  • 0

Hi there,

 

I've created a dynamic list which renders in a table where a user can add rows, enter data into the fields then click save to insert all the rows.

I am wanting to add the functionality to delete a row that may have been added by mistake.

 

I have got as far as:

public void deleteRow(){
    distribution.remove(0);
}

'distribution' is the name of the list.

 

The problem with this code is that it only removes the row with the index stated in the brackets. I'm wanting it to remove the row that the command button is in.

 

For extra reference here is the code for the table which the list renders in.

 

<apex:pageBlockTable rowClasses="even,odd" value="{!distribution}" var="dist" columns="3">
        
        <apex:column >
            <h1>Venue / Organisation:</h1><br/>
            <apex:inputField value="{!dist.Venue_Organisation__c}"/><p/>
            <h1>Date:</h1><br/>
            <apex:outputField value="{!dist.Date__c}"/>
        </apex:column>
        
        <apex:column >
            <h1>Resource:</h1><br/>
            <apex:outputField value="{!dist.Resource__c}"/><p/>
            <h1>Quantity:</h1><br/>
            <apex:inputField value="{!dist.Quantity__c}"/>
        </apex:column>
        
        <apex:column >
            <apex:commandButton value="remove" action="{!deleteRow}"/>
        </apex:column>          
        
        <apex:facet name="footer">          
                <apex:commandButton value="add" onMouseDown="javascript&colon;afunction()" action="{!addrow}"/>
        </apex:facet>
        
    </apex:pageBlockTable>

 

Many thanks in advance for your help

 

Ezmo

  • June 17, 2011
  • Like
  • 0

Hi, I'm not sure if this should be in the Apex or Visualforce section as it spans both.

 

Anyway, I've created a table of results from an SOQL query and I was wondering if it was possible to make it so that the results become links to the records they are representing.

 

I've pasted my controller extension and page code below.

 

Many thanks in advance

 

Eran

 

 

<apex:page standardController="Event_Services_Training__c" extensions="whatsOnExtension" tabstyle="What_s_On__tab">
    <apex:pageblock title="What's On?">
        <apex:pageblocktable var="a" value="{!training}" columns="6">
            <apex:column value="{!a.Title__c}"/>
            <apex:column value="{!a.Venue__c}"/>
            <apex:column value="{!a.Start_Date_of_Event__c}"/>
            <apex:column value="{!a.End_Date_and_Time_of_Event__c}"/>
            <apex:column value="{!a.Places_Remaining__c}"/>
            <apex:column value="{!a.Id}"/>
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>

 

public class whatsOnExtension{

    public final Event_Services_Training__c training;

    public whatsOnExtension(ApexPages.StandardController stdController) {
        this.training = (Event_Services_Training__c)stdController.getRecord();
    }

    public List<Event_Services_Training__c> trainingQuery = [SELECT Id, Name, title__c, Start_Date_of_Event__c, End_Date_and_Time_of_Event__c, venue__c, places_remaining__c 
                                                            FROM Event_Services_Training__c 
                                                            ORDER BY Start_Date_of_Event__c ASC NULLS FIRST]; 

    public List<Event_Services_Training__c> gettraining(){
        return trainingQuery;
    }

    public void table(){
        for(Event_Services_Training__c t : trainingQuery){
            Event_Services_Training__c tempTraining = new Event_Services_Training__c();
            trainingQuery.add(tempTraining);
        }
    }
}

 

 

  • June 03, 2011
  • Like
  • 0

Hi, I'm trying to create a report in a visualforce page for a custom object called Skills__c.

What I'm wanting to get is a table to show how many times a picklist option has been selected in a picklist called skill__c, to help understand what I mean here is an example:

 

Skill Total

Attention to Detail 5

Time Management 2

Reporting 1

 

Something like that.

 

So my question is, does anyone know any places I can find how to do this, I've found a few examples but not for custom objects and I'm struggling to change them. 

 

Thanks

 

Ezmo

  • March 16, 2011
  • Like
  • 0

Hi there, I'm creating an apex page to override the normal layout and I want a lookup field to have a default value which I am coding into the custom controller. The code I have so far is

 

 

Log_Book__c[] logbook;
    
    public Void<Log_Book__c> getlogbook(){
    
        logbook = [SELECT Id FROM Log_Book__c WHERE Owner.Id = :UserInfo.getUserId() LIMIT 1];
        }

    
    public List<Objective__c> objective = new List<Objective__c>();
    
    public List<Objective__c>  getObjective(){
       return objective; 
    }
    
    public void addObjective(){
        objective.add(new Objective__c(Log_Book__c = logbook.Id));
    }

 

 

when I try to save it I get this error

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Log_Book__c> 

 

I have tried just putting logbook instead of logbook.Id but then I get the following error:

Error: Compile Error: Invalid initial expression type for field Objective__c.Log_Book__c, expecting

 

Any ideas on this would be great.

 

Thank you for your time

 

Ezmo

  • March 09, 2011
  • Like
  • 0

Hi there, I'm quite new to coding and to apex so please bare with me. :smileywink:

 

I am trying to create an soql query which I essentially want to work like this:

 

SELECT Id FROM Log_Book__c WHERE Owner Id = Current User Id 

 

Does anyone know how I can achieve this?

 

Thank you for your time.

 

 

  • March 08, 2011
  • Like
  • 0

Hi all,

 

Just a quick one which I'm sure is really easy but I've been wracking my brains for a few hours on this one. 

 

I want to do an if function that would read along the lines of "If string x starts with string y".

 

Any help would be great!

 

Many thanks

 

Eran

  • November 20, 2012
  • Like
  • 0

Hi,

 

I've created a dynamic table which allows you to add rows which contain custom fields. Once the save button is clicked all the rows are inserted at once.

 

I'm wanting to add a 'delete row' button on each row.

 

My problem is that I need to be able to pass the row index to the remove method in the apex code.

 

Does anyone have any examples of this?

 

Many thanks in advance

 

Ezmo

  • June 27, 2011
  • Like
  • 0

Hi there,

 

I've created a dynamic list which renders in a table where a user can add rows, enter data into the fields then click save to insert all the rows.

I am wanting to add the functionality to delete a row that may have been added by mistake.

 

I have got as far as:

public void deleteRow(){
    distribution.remove(0);
}

'distribution' is the name of the list.

 

The problem with this code is that it only removes the row with the index stated in the brackets. I'm wanting it to remove the row that the command button is in.

 

For extra reference here is the code for the table which the list renders in.

 

<apex:pageBlockTable rowClasses="even,odd" value="{!distribution}" var="dist" columns="3">
        
        <apex:column >
            <h1>Venue / Organisation:</h1><br/>
            <apex:inputField value="{!dist.Venue_Organisation__c}"/><p/>
            <h1>Date:</h1><br/>
            <apex:outputField value="{!dist.Date__c}"/>
        </apex:column>
        
        <apex:column >
            <h1>Resource:</h1><br/>
            <apex:outputField value="{!dist.Resource__c}"/><p/>
            <h1>Quantity:</h1><br/>
            <apex:inputField value="{!dist.Quantity__c}"/>
        </apex:column>
        
        <apex:column >
            <apex:commandButton value="remove" action="{!deleteRow}"/>
        </apex:column>          
        
        <apex:facet name="footer">          
                <apex:commandButton value="add" onMouseDown="javascript&colon;afunction()" action="{!addrow}"/>
        </apex:facet>
        
    </apex:pageBlockTable>

 

Many thanks in advance for your help

 

Ezmo

  • June 17, 2011
  • Like
  • 0

Hi, I'm not sure if this should be in the Apex or Visualforce section as it spans both.

 

Anyway, I've created a table of results from an SOQL query and I was wondering if it was possible to make it so that the results become links to the records they are representing.

 

I've pasted my controller extension and page code below.

 

Many thanks in advance

 

Eran

 

 

<apex:page standardController="Event_Services_Training__c" extensions="whatsOnExtension" tabstyle="What_s_On__tab">
    <apex:pageblock title="What's On?">
        <apex:pageblocktable var="a" value="{!training}" columns="6">
            <apex:column value="{!a.Title__c}"/>
            <apex:column value="{!a.Venue__c}"/>
            <apex:column value="{!a.Start_Date_of_Event__c}"/>
            <apex:column value="{!a.End_Date_and_Time_of_Event__c}"/>
            <apex:column value="{!a.Places_Remaining__c}"/>
            <apex:column value="{!a.Id}"/>
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>

 

public class whatsOnExtension{

    public final Event_Services_Training__c training;

    public whatsOnExtension(ApexPages.StandardController stdController) {
        this.training = (Event_Services_Training__c)stdController.getRecord();
    }

    public List<Event_Services_Training__c> trainingQuery = [SELECT Id, Name, title__c, Start_Date_of_Event__c, End_Date_and_Time_of_Event__c, venue__c, places_remaining__c 
                                                            FROM Event_Services_Training__c 
                                                            ORDER BY Start_Date_of_Event__c ASC NULLS FIRST]; 

    public List<Event_Services_Training__c> gettraining(){
        return trainingQuery;
    }

    public void table(){
        for(Event_Services_Training__c t : trainingQuery){
            Event_Services_Training__c tempTraining = new Event_Services_Training__c();
            trainingQuery.add(tempTraining);
        }
    }
}

 

 

  • June 03, 2011
  • Like
  • 0

Hi, I'm trying to create a report in a visualforce page for a custom object called Skills__c.

What I'm wanting to get is a table to show how many times a picklist option has been selected in a picklist called skill__c, to help understand what I mean here is an example:

 

Skill Total

Attention to Detail 5

Time Management 2

Reporting 1

 

Something like that.

 

So my question is, does anyone know any places I can find how to do this, I've found a few examples but not for custom objects and I'm struggling to change them. 

 

Thanks

 

Ezmo

  • March 16, 2011
  • Like
  • 0

Hi there, I'm creating an apex page to override the normal layout and I want a lookup field to have a default value which I am coding into the custom controller. The code I have so far is

 

 

Log_Book__c[] logbook;
    
    public Void<Log_Book__c> getlogbook(){
    
        logbook = [SELECT Id FROM Log_Book__c WHERE Owner.Id = :UserInfo.getUserId() LIMIT 1];
        }

    
    public List<Objective__c> objective = new List<Objective__c>();
    
    public List<Objective__c>  getObjective(){
       return objective; 
    }
    
    public void addObjective(){
        objective.add(new Objective__c(Log_Book__c = logbook.Id));
    }

 

 

when I try to save it I get this error

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Log_Book__c> 

 

I have tried just putting logbook instead of logbook.Id but then I get the following error:

Error: Compile Error: Invalid initial expression type for field Objective__c.Log_Book__c, expecting

 

Any ideas on this would be great.

 

Thank you for your time

 

Ezmo

  • March 09, 2011
  • Like
  • 0

Hi there, I'm quite new to coding and to apex so please bare with me. :smileywink:

 

I am trying to create an soql query which I essentially want to work like this:

 

SELECT Id FROM Log_Book__c WHERE Owner Id = Current User Id 

 

Does anyone know how I can achieve this?

 

Thank you for your time.

 

 

  • March 08, 2011
  • Like
  • 0