• ColinKenworthy2
  • NEWBIE
  • 210 Points
  • Member since 2010

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 63
    Replies

I'm becoming mad with this error. I checked the similar post . In those i see the error and in my code i don't see anything wrong.

 

Error is :  Error: Unknown property 'CO01_RegSport_Data.RegistrationChild.indexChild' 

 

The VF page is :

<apex:pageBlockTable value="{!data.regChildren}" var="child">
	<apex:column >
		<apex:facet name="header">number</apex:facet>
		<apex:outputText value="{!child.indexChild}" />
	</apex:column>
	<apex:column >
		<apex:facet name="header">{!labels.FirstName__c}</apex:facet>
		<apex:inputField value="{!child.reg.Firstname__c}" />
	</apex:column>
</apex:pageBlockTable>

 {!child.reg.Firstname__c} is working fine, but not {!child.indexChild}

 

and the controller is :

public class CO01_RegSport_Data{

    private Registration__c regMain;
    private List<RegistrationChild> regChildren;


    public CO01_RegSport_Data(String userId, CO01_RegSport mainclass){
        ...
    }
	

    public Registration__c getRegMain(){return regMain;}
    public List<RegistrationChild> getRegChildren(){return regChildren;}
   
    public PageReference addRegistrationChild(){
        if (regChildren == null) regChildren = new List<RegistrationChild>();
        regChildren.add(new RegistrationChild(regMain, 'Child', this, empl, regChildren.size()+1));
        return null;
    }

    public class RegistrationChild{
        private Registration__c reg;
        private Registration__c regParent;
        private CO01_RegSport_Data data;
        private Employee__c empl;
		private Integer indexChild;

        public RegistrationChild(Registration__c regParent, String relation, CO01_RegSport_Data data, Employee__c empl, Integer indexChild){
            
            reg = new Registration__c();
            ...
			this.indexChild = Integer.valueOf(indexChild);
        }

        public Integer getIndexChild(){return indexChild;}
        public Registration__c getReg(){return reg;}
    }

}

 

Please help me. Tnx in advance.

  • February 02, 2012
  • Like
  • 0

I'm trying to populate a list from a soql statment. It's currently populating 1 item but I'm not sure where the loop should go.

  <apex:selectList id="Modelbox" value="{!Models}" size="1" title="Type" onchange="searchServer(this.options[this.selectedIndex].text)">                                
  <apex:selectOptions value="{!items}"></apex:selectOptions>                              
  </apex:selectList>

 Here's the controller

    //Variables
    String[] models = new String[]{};

    
    //sobject
    public IT_Asset__c ITA {get;set;}
     
   
    public AssetManController() 
    {
     ITA=[SELECT Workstation_Model__c FROM IT_Asset__c]; 
        
    }
    public List<SelectOption> getItems() 
        {
        List<SelectOption> options = new List<SelectOption>();
        for(integer i=0;i<30;i++)
        {
        options.add(new SelectOption(ITA.Workstation_Model__c,ITA.Workstation_Model__c));
        }
        
        
        return options;
        }

       public string[] getModels()
       {
           return models;
       }
      public void setModels(string[] models)
       {
           this.models=models;
       }

 

 

 

I am using an inputTextarea for a custom outgoing email but my vf page cannot maintain line breaks or spaces. It seperates every word with one char long space regardless of how you indented your text.

 

e.g: I type:

'

 a     b

     c

 d    

    e    f  '

 

I'll get:

'a b c d e f'

 

thanks

 

Hello,

 

I have the following simple trigger to add a custom field called "Account Name" on the task object:

 

trigger TaskLinkToParentAccount on Task(before insert, before update) {

    for(Task e : Trigger.new) {
        String Link_Id = e.WhoId;
        String Account_ID = '';  
        String Account_Name = '';
        if    (
            Link_Id.startsWith('003')//Contact link
            )
        {         
            Account_ID = [SELECT AccountId FROM Contact WHERE id = :Link_Id limit 1].AccountId;
            Account_Name = [SELECT Name FROM Account WHERE id = :Account_ID limit 1].Name;
        }

        e.Account_Name__c = Account_Name;
        }
   }

 

Here is the test class:

 

public static testMethod void testTaskLinkToParentAccount(){     
    Account a = new Account(name='TestAccount');
    insert a;
    Contact c = new Contact(lastname='Smith');
    insert c;
    Task t = new Task(subject='test', whoid=c.id);
    insert t;
}

 

I am getting the following error when I try to validate deployment:

 

*** Deployment Log ***
# Test Results:

Run Failures:
  testClass.testTaskLinkToParentAccount System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TaskLinkToParentAccount: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.TaskLinkToParentAccount: line 12, column 28: []

 

This trigger runs fine in the sandbox so I'm missing something in the test class. Hopefully an easy fix. Any ideas?

 

-Ted

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateSARQ caused an unexpected exception, contact your administrator: UpdateSARQ: execution of AfterUpdate caused by: System.StringException: Invalid id: Subject_Area__r.Name: Trigger.UpdateSARQ: line 14, column 12

 

My Trigger:

 

trigger UpdateSARQ on Course_History__c (before insert,before update) {
List<Course_History__c> htoUpdte = new List<Course_History__c>();
Map<Id,String> rTypes = new Map<Id,String>();
Map<Id,Decimal> rTypes2 = new Map<Id,Decimal>();

for(Subject_Area_RQ__c rType :[SELECT Id,Subject_Area__r.Name,GL_Term_Value__c FROM Subject_Area_RQ__c]) {
rTypes.put(rType.Id,rType.Subject_Area__r.Name);
rTypes2.put(rType.Id,rType.GL_Term_Value__c);
}

for(Course_History__c ch: trigger.new)
{

if(rTypes.get('Subject_Area__r.Name')== ch.Subject_Area__c && rTypes2.get('GL_Term_Value__c')== ch.GL_Term_Value__c ){
ch.SARQ__c=rTypes.get('Id');
}

htoUpdte.add(ch);

}
}

 Please Help

How do you create a new record on an object different from the trigger?

 

More specifically whenever I create a record in 1 object, I want to create a corresponding record in another object.

 

So far I have the following, but I get an error:

System.NullPointerException: Attempt to de-reference a null object

 

 

 

trigger UpdateLabor_After on Labor__c (after insert, after update) { String RelatedLabor = null, RelatedSchool = null, RelatedDistrict = null, temp_id = null; Labor__c[] labor = trigger.new; RelatedSchool = labor[0].Related_School__c; RelatedDistrict = labor[0].Related_District__c; if(System.Trigger.isinsert) { Student_Attendance_Labor__c [] newrecord; RelatedLabor = labor[0].Id; newrecord[0].Related_Labor__c = RelatedLabor; newrecord[0].Related_School__c = RelatedSchool; newrecord[0].Related_District__c = RelatedDistrict; insert newrecord [0]; }

 

 The error looks like its related to the line:

	Student_Attendance_Labor__c [] newrecord;

 

How do I define a record that doesn't yet exist?

 

  • February 18, 2010
  • Like
  • 0

Hi,

 

I think I read in the apex developer's guide that it is possible to have up to 10 (or 25?) email addresses in the "to" field of the mail object for a single outgoing email.  All of the examples I have found show just a single address, something like this:

 

OutMail.setToaddresses('joe.blow@acme.com');

 

Ideally, I'd like to be able to send an email to anywhere from 3-8 addresses.  I am able to send to 3 addresses, by assigning one email field to the setToaddresses,  one to the setCcaddresses, and one to the setBccaddresses.

 

Also, it appears to me that only fields created as an email type work.  I've tried to create a text field and put in multiple email addresses (ex 'joe@acme.com', bill@acme.com') and assign this to the setToaddresses mail object, but no dice. 

 

Right now, I feel like I'm limited to 3 email addresses.  Does anyone know how to combine multiple email addresses (from individual custom fields or one big text field) into the setToaddresses mail object?

Hey all... I have a bunch of page refs that do separate things, but send the user back to the same page each time.

 

 

Is there a way to call one page ref within another?

 

example:

 

Public PageReference viewRecord() { PageReference toPage = page.myPage; toPage.getParameters().put('id', my.id); toPage.setRedirect(true); return toPage; } public pageReference doSomething() { integer iAxns, ia; integer numSelectedAxns = selectedAxns.size(); //Loop through the contacts one by one and set them up for ( ia = 0;ia < numSelectedAxns; ia++ ) { IMACtion__c axnToGet = selectedAxns.get(ia); //Now map the fields axnToGet.Shipment_status__c = 'Wow it worked!'; } //Then insert the contacts update actions; //So assuming all that works... let's go look at our record

...Can I call the other page ref right here? How?
}

 See what I mean?

 

 

Thanks!

 

 

  • February 17, 2010
  • Like
  • 0

I have a workflow on Opportunity checking the record type and a picklist value, I see it in the debug log as I edit the oppy, but as soon as I pick the value in the picklist that makes the criteria evaluate to true nothing happens and I just see WF_RULE_NOT_EVALUATED!!

The Opportunity WF rule is:

"When a record is created, or when a record is edited and did not previously meet the rule criteria", run when the formula evaluates to true:

($RecordType.DeveloperName = 'Publishing') && ISPICKVAL(StageName, 'Meeting Held')

 

From the debug log when I set the oppy stage to Meeting Arranged

15:35:20.156 (156288000)|WF_RULE_EVAL_BEGIN|Workflow
15:35:20.156 (156323000)|WF_CRITERIA_BEGIN|[Opportunity: Test Oppy 4 006M0000003XKGE]|Publishing New Task|01QM00000004Upk|ON_CREATE_OR_TRIGGERING_UPDATE
15:35:20.156 (156924000)|WF_FORMULA|Formula:($RecordType.DeveloperName = 'Publishing') && ISPICKVAL(StageName, 'Meeting Held')|Values:StageName=Meeting Arranged, $RecordType.DeveloperName=Publishing
15:35:20.156 (156945000)|WF_CRITERIA_END|false

 ... evaluating to False as expected.

 

Now when I set the stage to Meeting Held I expect it to evaluate to True and do all the emails, tasks, field updates etc.. but nothing happens and I just see

15:35:40.146 (146234000)|WF_RULE_EVAL_BEGIN|Workflow
15:35:40.146 (146268000)|WF_CRITERIA_BEGIN|[Opportunity: Test Oppy 4 006M0000003XKGE]|Publishing New Task|01QM00000004Upk|ON_CREATE_OR_TRIGGERING_UPDATE
15:35:40.147 (147065000)|WF_RULE_NOT_EVALUATED

 

Can anyone explain this, I have no idea whats going on, I've got the right record type and the right picklist value to run the workflow but nothing is happening.

 

I've used YUI2 (2.9.0) to successfully implement a modal dialog as described in this sfdc tutorial:

http://wiki.developerforce.com/page/Tutorial:_Modal_Dialogs_in_Visualforce_using_the_Yahoo!_User_Interface_Library

 

I've then gone on to use this in a command link in a page block table so that each each table row has a different modal dialog.

 

But YUI2 is no longer in development, it stops at 2.9.0. Yahoo! is on YUI3 and the libraries are different and it works in a different way to YUI2. I had a try but my panels would not show and my vavascript variables were undefined.

 

Is anyone using YUI3 with visualforce to create modal dialogs and can post some example code or skeleton code?

 

 

Thanks.

On the Contact new / edit screen, when you lookup an Account, the Address firelds from the Account are filled into the Contact address fields on the screen.

 

I've now added a custom field to Account and Contact objects called "Building Name" - does anyone know of a way to get the new field to auto-populate on the Contact screen as well ?

Anyone done something similar?

 

 

Thanks.

I can only think of setting up a new user for data loader jobs and testing for that user in the Userinfo class?

 

Can anyone think of another way?

If you make a multi-select picklist dependent on a picklist then use them in a VF page the left/right arrows will vanish as soon as you perform an action method.

e.g. create a custom object called MSP. Now on object MSP__c create a required text field, a picklist (2 or 3 values) and a multi-select picklist (4 or 5 values).

 

Field Label       API Name             Data Type
First Name        First_Name__c        Text(25) - required to save record
Master Picklist   Master_Picklist__c   Picklist
Test MSP          Test_MSP__c          Picklist (Multi-Select)

 In the MSP tab create a record.

Create the following VF page and Class (extensions controller)

 

public class MSP_EXT {

    public MSP__c MSPrec {get; set;}
    
    public MSP_EXT(ApexPages.StandardController controller) {
        MSPrec = (MSP__c) controller.getRecord();
    }
    
    public PageReference mySave() {
        update MSPrec;
        return null;
    }
}

VF page testMSP

 

<apex:page id="page1" standardController="MSP__c" extensions="MSP_EXT" >
    <apex:form id="form1">
        <apex:pageBlock id="pb1">

            <apex:pageBlockButtons id="pbb1" location="both">
                <apex:commandButton id="btn1" value="Save" action="{!mySave}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection id="pbs1">

                <apex:inputField id="inp1" value="{!MSP__c.First_Name__c}"/>
                <apex:inputField id="inp2" value="{!MSP__c.Test_MSP__c}"/>
                <apex:inputField id="inp3" value="{!MSP__c.Master_Picklist__c}"/>

            </apex:pageBlockSection>

            <apex:pageMessages id="msgs1"/>

        </apex:pageBlock>

    </apex:form>
</apex:page>

So now try your apex page with the record you created:    yourInstance.salesforce.com/apex/testMSP?id=yourRecordId

 

 

Now save your record with and without a value in the required text field - no problems right? Everything works fine in the VF page and the Standard page.

 

Now with the Field Dependencies button make the multi-select picklist dependent on the picklist and make a few dependent values.

In the MSP Tab the Standard page works fine trying to edit the record with or without a value in the text field.

Go to the VF page again and whether there is a value in the text field or not, when you click the button the multi-select picklists left and right arrows vanish. (VF sends them with a display:none style attribute).

 

 

Is there some function or global var that I can use to get from my VF page to a standard page? I want the standard email edit page for my email template.

 

In sandbox in my VF page I have a button that executes this javascript

 

location.replace("/email/author/emailauthor.jsp?retURL=/{!Onboarding_Request__c.Id}&p3_lkid={!Onboarding_Request__c.Id}&template_id=00X200000013Z9D&p26=0D220000000CaoV:abc@xyz.com:XYZ GLOBAL mailbox&p24=...etc.

 but it takes me to https://c.cs2.visual.force.com/email/author/emailauthor.jsp....etc.

... whereas where I really want to go is to https://cs2.salesforce.com/email/author/emailauthor.jsp....etc.  (the sandbox domain for my regular standard pages).

 

Now the emailauthor page from the visual.force.com domain does work however it is implemented slightly differently in htat the email preview is in a fixed size area with no scrollbars. From the standard domain it is much nicer in that the preview resizes to the email and it can all be seen.

 

So what I'd like to do is something like:

 

location.replace("{!$STDDOMAIN}/email/author/emailauthor.jsp?retURL=/{!Onboarding_Request__c.Id}&p3_lkid=...etc.

 if such a function or variable should exist.

 

Is anyone aware of a way to do this?

 

TIA.

 

 

 

I have a workflow on Opportunity checking the record type and a picklist value, I see it in the debug log as I edit the oppy, but as soon as I pick the value in the picklist that makes the criteria evaluate to true nothing happens and I just see WF_RULE_NOT_EVALUATED!!

The Opportunity WF rule is:

"When a record is created, or when a record is edited and did not previously meet the rule criteria", run when the formula evaluates to true:

($RecordType.DeveloperName = 'Publishing') && ISPICKVAL(StageName, 'Meeting Held')

 

From the debug log when I set the oppy stage to Meeting Arranged

15:35:20.156 (156288000)|WF_RULE_EVAL_BEGIN|Workflow
15:35:20.156 (156323000)|WF_CRITERIA_BEGIN|[Opportunity: Test Oppy 4 006M0000003XKGE]|Publishing New Task|01QM00000004Upk|ON_CREATE_OR_TRIGGERING_UPDATE
15:35:20.156 (156924000)|WF_FORMULA|Formula:($RecordType.DeveloperName = 'Publishing') && ISPICKVAL(StageName, 'Meeting Held')|Values:StageName=Meeting Arranged, $RecordType.DeveloperName=Publishing
15:35:20.156 (156945000)|WF_CRITERIA_END|false

 ... evaluating to False as expected.

 

Now when I set the stage to Meeting Held I expect it to evaluate to True and do all the emails, tasks, field updates etc.. but nothing happens and I just see

15:35:40.146 (146234000)|WF_RULE_EVAL_BEGIN|Workflow
15:35:40.146 (146268000)|WF_CRITERIA_BEGIN|[Opportunity: Test Oppy 4 006M0000003XKGE]|Publishing New Task|01QM00000004Upk|ON_CREATE_OR_TRIGGERING_UPDATE
15:35:40.147 (147065000)|WF_RULE_NOT_EVALUATED

 

Can anyone explain this, I have no idea whats going on, I've got the right record type and the right picklist value to run the workflow but nothing is happening.

 

I want to create a field called password 

<apex:inputtext    value="{!Password}" />

 

 

I'm becoming mad with this error. I checked the similar post . In those i see the error and in my code i don't see anything wrong.

 

Error is :  Error: Unknown property 'CO01_RegSport_Data.RegistrationChild.indexChild' 

 

The VF page is :

<apex:pageBlockTable value="{!data.regChildren}" var="child">
	<apex:column >
		<apex:facet name="header">number</apex:facet>
		<apex:outputText value="{!child.indexChild}" />
	</apex:column>
	<apex:column >
		<apex:facet name="header">{!labels.FirstName__c}</apex:facet>
		<apex:inputField value="{!child.reg.Firstname__c}" />
	</apex:column>
</apex:pageBlockTable>

 {!child.reg.Firstname__c} is working fine, but not {!child.indexChild}

 

and the controller is :

public class CO01_RegSport_Data{

    private Registration__c regMain;
    private List<RegistrationChild> regChildren;


    public CO01_RegSport_Data(String userId, CO01_RegSport mainclass){
        ...
    }
	

    public Registration__c getRegMain(){return regMain;}
    public List<RegistrationChild> getRegChildren(){return regChildren;}
   
    public PageReference addRegistrationChild(){
        if (regChildren == null) regChildren = new List<RegistrationChild>();
        regChildren.add(new RegistrationChild(regMain, 'Child', this, empl, regChildren.size()+1));
        return null;
    }

    public class RegistrationChild{
        private Registration__c reg;
        private Registration__c regParent;
        private CO01_RegSport_Data data;
        private Employee__c empl;
		private Integer indexChild;

        public RegistrationChild(Registration__c regParent, String relation, CO01_RegSport_Data data, Employee__c empl, Integer indexChild){
            
            reg = new Registration__c();
            ...
			this.indexChild = Integer.valueOf(indexChild);
        }

        public Integer getIndexChild(){return indexChild;}
        public Registration__c getReg(){return reg;}
    }

}

 

Please help me. Tnx in advance.

  • February 02, 2012
  • Like
  • 0

I have an apex:InputText field.  Hitting Enter in the field causes the next CommandButton on the page to be executed.  I do not what that to happen.  The commandButton is not even the next element on the page.  I have several inputText entries.  If I hit enter in the first one, the next CommandButton on the page is executed.

 

Anyone know if there's a way to defeat that functionality?

 

I see documentation on the "accessKey" attribute on commandButton but no details.  I don't have that specified and don't know if specifying anything here could cause the functionality to be defeated.

 

Any ideas?

 

There's one case in my application where hitting Enter and executing the next CommandButton on the page would make sense.  Everywhere else it does not.  I really want to turn that functionality off in those cases.

   

hai

I had  created  an  Multiselect Picklist in sale__c.and i have created a pagelayout and place Sale__c page layout .

I  have been stored the picklist value in string list..

I have picklistlist values are A,B,C

Those selected values i have taken in list

but those selected values must display like that 

variables[0] A 
variables[1] B 
variables[1] C

they are displaying in  debuglog but not displaying in visulforce page

 

 

Class

public class os1 {
String id;
public Sale__c a1
{get;set;}


public list<String> str{get;set;}
public List<String> BrowseFile{get;set;}
public os1(ApexPages.StandardController stdcontroller)
{

this.id=ApexPages.currentPage().getParameters().get('id');
}
public PageReference submit()
{
Sale__c a1=[select id,name,variable__c from Sale__c where id =:this.id];

BrowseFile = new List<String>();


BrowseFile.add(a1.variable__c);

 

string[] aaa=browseFile;
system.debug('xxxxxxxxxxxxxxx'+aaa);
for(String s: aaa)
{
Integer n = s.length();


String[] result=s.split(';',3);

 


Set<String> temp = new Set<String>();
for( Integer i = 0; i<result.size(); i++)
{

string str=result[i];

system.debug('xxxxxxxxxxxxxxgfgxyuuiff'+str);

}

}
return null;
}
}

visualforcepage

<apex:page standardController="sale__c" extensions="os1" action="{!submit}" >
<apex:pageBlock >
<apex:form >
pickvalue
<apex:inputfield value="{!a1.Variable__c}"/>
<br/>
Selected variables
<apex:outputText value="{!BrowseFile}" />
<br/>
dfd
<apex:outputText value="{!str}" >

</apex:outputText>

<apex:repeat value="{!str}" var="temp" >
TEST{!temp}
</apex:repeat>

</apex:form>
</apex:pageBlock>
</apex:page>


here into str is an list of an string.. but in this no values are beeen pass it

it must display like this

temp[0] ='A'

temp[1] ='B'

temp[2] ='C'

but the values are not displaying in visualforcepage bt the values are being displayed in debuglog

 

thanks in advance

  • February 02, 2012
  • Like
  • 0

I am trying to Auto populate the name of a client in Related to Client field in Idea Page .

Idea page is a salesforce standard page.

Onclick of button I have to pupulate the relateded client name in search test box.

I am passing the value for Related to client field as below in URL which is written on button logic

 

https://****.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp 

 

On click of button I am getting Id in URL as below

https://***.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

 

Can anyone suggest Related to client field is not populating with the value which i am passing in URL. 

 

Thanks

Ajit

  • February 02, 2012
  • Like
  • 0

Hi,


I am facing a problem in my trigger class. I am using Trigger Helper class for all my business logic. Here in this example, my "businessRule1" method validate the record, add error for invalid case then perform the business logic. The "businessRule2" is independent from "businessRule1" and should call only if record is not containing any error.

One way is to implement this is "businessRule1" should return some flag "result" that every thing is OK or not.

Here I just want to know :

1. Do we have any other alternative way for this?
2. Any helper method exists like.. "hasError", "isError" on object (i checked but didn't find anything related to this on SObject)
3. What if I want to get all error messages here?
4. We can use "ApexPages" helper methods in our custom controller class but what about normal Apex classes or Triggers?

trigger MyTrigger on Test__c (before update) {
    TestHelper.businessRule1(Trigger.new);
    
    boolean hasError = false;
    // hasError = ApexPages.hasMessages();
    
    if(!hasError) {
         TestHelper.businessRule2(Trigger.new);
    }
}

---------------------------
public class TestHelper{
    public static void businessRule1(List<Test__c> newList){
        if(true){ // failed in some business condition
            newList.get(0).addError('Test Error');
//          newList.get(0).name.addError('Test Error on field');
        }
    }
    
    
    public static void businessRule2(List<Test__c> newList){
        // perform some other business logic here
    }
}

 Thanks in advance.

  • February 01, 2012
  • Like
  • 0

Hi all,

 

I created an object called Locations that pulls data from another custom object called FNL.  I created a button on the Opportunity object that will allow a rep to lookup a given FNL location and create a Location item.  I currently have the following features working: The FNL search fields, the matching values based on the search and the existing Locations that are already associated to the Opportunity.

 

What I am having trouble with is being able to create checkboxes next to the matching values that are returned that will allow me to add them to the Opportunity.

 

public class LocationSearchController {

 public PageReference Cancel() {
        return null;
    }

        public Opportunity o { get; set; }
    Id myid= ApexPages.currentPage().getParameters().get('id');
    
    public PageReference ViewData() {

    return null;
    }
     
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of FNL to display
  public List<FNL__c> fnl {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to Name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public LocationSearchController() {
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    runQuery();
   
    o = [select Id, Name, OwnerId, Account.Name, RecordType.Name, Existing_Order_Number__c, AboveNet_Order_Number__c, Quote_MRC_Total__c, 
                 Quote_NRC_Total__c, TechChange__c, Commencement_Date__c, PrepaymentAmount__c, ImplementationComments__c, BillingComments__c 
                 from Opportunity 
                 where id = :myid];     
  }
  
  public Opportunity getOpportunity() {
            return o;
  }
 
 
    //Our collection of the class/wrapper objects cLoctact 
    public List<cLocation> locationList {get; set;}

    //This method uses a simple SOQL query to return a List of Contacts
    public List<cLocation> getLocations() {
        if(locationList == null) {
            locationList = new List<cLocation>();
            for(Location__c c : [select Id, Street__c, City__c, State__c, zip__c, Entrances_Required__c, Location__c, Proposed_Demarc__c,
                            Country__c, FNL_Building_Code__c, Location_Type__c, Available_Entrance__c, Building_Fiber_Demarc__c, Name, 
                            Building_is_OnNet__c, Building_Type__c, Suite__c, FNL_Street__c from Location__c where Account__c = :o.AccountId]) {
                // As each contact is processed we create a new cLoctact object and add it to the contactList
                locationList.add(new cLocation(c));
            }
        }
        return locationList;
    }
   
     public PageReference processSelected() {

        //We create a new list of Locations that we be populated only with FNL if they are selected
        List<Location__c> selectedLocations = new List<Location__c>();

        //We will cycle through our list of cLocations and will check to see if the selected property is set to true, if it is we add the FNL to the selectedLocations list
        for(cLocation cLoc : getLocations()) {
            if(cLoc.selected == true) {
                selectedLocations.add(cLoc.loc);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc = new List<Location__c>();

        for(Location__c loc : selectedLocations) {
            
            Location__c nloc; 
            nloc = loc.clone(false);
            nloc.Opportunity__c = o.Id;
            nloc.Account__c = null;
            
            newloc.add(nloc);
        }
        
        insert newloc;
        return null;
    }

//Our collection of the class/wrapper objects cLocations 
    public List<dfnl> fnlList {get; set;}

    //This method uses a simple SOQL query to return a List of FNL
    public List<dfnl> getfnl() {
        if(fnlList == null) {
            fnlList = new List<dfnl>();
               for(FNL__c d : Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20') ) 
            {
                // As each contact is processed we create a new cFNL object and add it to the Location List
                fnlList.add(new dfnl(d));
             }
        }
        return fnlList;
    }
   
     public PageReference processSelectedf() {

        //We create a new list of Contacts that we be populated only with Contacts if they are selected
        List<FNL__c> selectedfnl = new List<FNL__c>();

        //We will cycle through our list of cLoctacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedLocations list
        for(dfnl dF : getfnl()) {
            if(dF.selected == true) {
                selectedfnl.add(dF.fnl2);
            }
        }

        // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
        List <Location__c> newloc1 = new List<Location__c>();

        for(FNL__c fnl : selectedfnl) {
            
            Location__c nloc1;
            nloc1.Access_Type__c = fnl.Access_Type__c;
            nloc1.Assets__c = fnl.Assets__c;
            nloc1.FNL_Building_Code__c = fnl.Building_Code__c;
            nloc1.Building_Fiber_Demarc__c = fnl.Building_Fiber_Demarc__c;
            nloc1.Building_Type__c = fnl.Building_Type__c;
            nloc1.Datacenter__c = fnl.Datacenter__c;
            nloc1.Entrances_Required__c = fnl.Entrance__c;
            nloc1.Street__c = fnl.FNL_Street__c;
            nloc1.Suite__c = fnl.FNL_Suite__c;
            nloc1.City__c = fnl.FNL_City__c;
            nloc1.State__c = fnl.FNL_State__c;
            nloc1.Zip__c = fnl.FNL_Zip__c;
            nloc1.Country__c = fnl.FNL_Country__c;
            nloc1.IP_POP__c = fnl.IP_POP__c;
            nloc1.IP_VPOP__c = fnl.IP_VPOP__c;
            nloc1.LH_POP__c = fnl.LH_POP__c;
            nloc1.LH_VPOP__c = fnl.LH_VPOP__c;
            nloc1.Opportunity__c = o.Id;
            nloc1.Account__c = null;
            
            newloc1.add(nloc1);
        }
        
        insert newloc1;
        return null;
    }


    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class cLocation {
        public Location__c loc {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public cLocation(Location__c c) {
            loc = c;
            selected = false;
         }
    }
     
      // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    public class dFNL {
        public FNL__c fnl2 {get; set;}
        public Boolean selected {get; set;}

     //This is the contructor method. When we create a new cLoctact object we pass a Contact that is set to the con property. We also set the selected value to false
        public dFNL(FNL__c d) {
            fnl2 = d;
            selected = false;
         }
    }
  
     
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      fnl = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String Name = Apexpages.currentPage().getParameters().get('Name');
    String fnlcity= Apexpages.currentPage().getParameters().get('fnlcity');
    String buildingcode= Apexpages.currentPage().getParameters().get('buildingcode');
 
    soql = 'select Name, FNL_Suite__c, FNL_City__c, FNL_State__c, FNL_Zip__c, Building_Code__c from FNL__c where Name != null';
    if (!Name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!fnlcity.equals(''))
      soql += ' and FNL_City__c LIKE \''+String.escapeSingleQuotes(fnlcity)+'%\'';
    if (!buildingcode.equals(''))
      soql += ' and Building_Code__c LIKE \''+String.escapeSingleQuotes(buildingcode)+'%\''; 
 
    // run the query again
    runQuery();

    return null;
  }
 

}

 

<apex:page controller="LocationSearchController" sidebar="false">
 
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockButtons >
            <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
            <apex:commandButton value="Cancel" action="{!Cancel}" rerender="table" onclick="window.top.close();"/>
         </apex:pageBlockButtons>
         <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!locations}" var="c" id="table">
            <apex:column >
            <!-- This is our selected Boolean property in our wrapper class -->
             <apex:inputCheckbox value="{!c.selected}"/>
            </apex:column>
                <!-- This is how we access the contact values within our cContact container/wrapper -->
                   <apex:column value="{!c.loc.Name}" />
                   <apex:column value="{!c.loc.Street__c}" />
                   <apex:column value="{!c.loc.City__c}" />
                   <apex:column value="{!c.loc.State__c}" />
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
    
   <apex:form >
      <apex:pageMessages id="errors" />
 
      <apex:pageBlock title="FNL Lookup" mode="edit">
         <table width="100%" border="0">
            <tr>  
               <td width="200" valign="top">
                  <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                     <script type="text/javascript">
                        function doSearch() {
                        searchServer(
                        document.getElementById("Name").value,
                        document.getElementById("fnlcity").value,
                        document.getElementById("buildingcode").value);
                        } 
                     </script> 
 
                     <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                        <apex:param name="Name" value="" />
                        <apex:param name="fnlcity" value="" />
                        <apex:param name="buildingcode" value="" />
                     </apex:actionFunction>
 
                     <table cellpadding="2" cellspacing="2">
                        <tr>
                           <td style="font-weight:bold;">Street<br/>
                              <input type="text" id="Name" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">City<br/>
                              <input type="text" id="fnlcity" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                        <tr>
                           <td style="font-weight:bold;">Building Code<br/>
                              <input type="text" id="buildingcode" onkeyup="doSearch();"/>
                           </td>
                        </tr>
                     </table>
                  </apex:pageBlock>
               </td>
                 <td valign="top">
                    <apex:pageBlock mode="edit" id="results">
                    <!-- In our table we are displaying the cContact records -->
                       <apex:pageBlockTable value="{!fnl}" var="d" id="FNLtable">

                            <apex:column value="{!d.Name}" />
                            <apex:column value="{!d.FNL_Suite__c}" />
                            <apex:column value="{!d.FNL_City__c}" />
                            <apex:column value="{!d.FNL_State__c}" />
                            <apex:column value="{!d.FNL_Zip__c}" />
                            <apex:column value="{!d.Building_Code__c}" />
                       </apex:pageBlockTable>
                       <apex:pageBlockButtons >
                          <apex:commandButton value="Add Selected Location to Opportunity" action="{!processSelected}" rerender="table" onclick="window.top.close()" oncomplete="javascript&colon;closeRefresh('{!Opportunity.Id}');"/>
                       </apex:pageBlockButtons>
                    </apex:pageBlock>
                 </td>
            </tr>
         </table>
            <apex:pageBlock title="Debug - SOQL" id="debug">
               <apex:outputText value="{!debugSoql}" />           
            </apex:pageBlock>    
      </apex:pageBlock>
   </apex:form>
</apex:page>

 Any help would be appriciated.

 

Thanks.

Good day, 

 

Is there a chance for a user who currently having language setting in 'English'  and when object save, the picklist value will save in specific language based on given parameter. 

 

ie : if parameter lang='es' , spanish translation value of the selected picklist value will be save instead of english

 

Thank you ! 

  • January 07, 2010
  • Like
  • 0