• rmeh
  • NEWBIE
  • 260 Points
  • Member since 2010

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 60
    Replies

Hi,

 

I have a lookup field called Related_Contact__c on an Opportunity which is a lookup to a Contact record. How can I access the Account for this Contact through the lookup field. I am trying the following, but doesnt seem to work - the error report tells me that there is an "unexpected token: Account"

 

SELECT id, StageName, Sub_Stage__c, Start_Date__c, End_Date__c FROM Opportunity WHERE (Related_Contact__c.Account:=Account)

 

The comparison I am trying to make here is between the Account field of the Related_Contact__c lookup and the Account field on the Opportunity itself.

 

Any recommendations?

I am very new to SF, but I'm building out a Student Recruiting App for 
my org.  I would love some feedback on the design of this trigger I 
just created.  I'm not sure how much background you need on the data 
structure of the app to provide feedback, but I will give you a basic 
overview. 

 

  • Education Object is detail to to Contact - used to show all schools a 
    prospect has attended.
  • Education has Account Lookup field for link back to School(Account 
    Record) 
  •  Enrollment is Child to Contact - used to Inquiry through graduation 
    for students 
  •  Application is Child to Enrollment 
  •  Document is Child to Application 

I hope that's enough to make sense of it all.  Here is the trigger.  It works just fine, but I 
would love to hear from the experts if this looks like it will scale 
well and any other feedback you are willing to offer. 

 

trigger CreateDocuments on Application__c (after insert) { 

List<Document__c> createdocument = new List <Document__c> {}; 
	for (Application__c app : trigger.new) { 
		List<Contact> c=[SELECT Id,Name FROM Contact WHERE 
		Id=:app.Contact__c]; 
		List<Education__c> ed = [SELECT School__c FROM Education__c WHERE 
		Student__c=:c]; 
		if(app.Recieved_Method__c <> 'Online'){ 
			for(Education__c e : ed){ 
			createdocument.add(new Document__c ( Name = 'Transcript', 
			Application__c =app.id,School__c=e.School__c,Contact__c=app.Contact__c)); 
			} 
		createdocument.add(new Document__c ( Name = 'Recommendation 1', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		createdocument.add(new Document__c ( Name = 'Recommendation 2', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		} 
	} 
try { 
	insert createdocument; 
} 
catch (Exception Ex) 
{ 
system.debug(Ex); 
}

 

Good day. Hye I'm new in this area and i'm about to create a VF page that will create 4 columns in Page Layout.

 

I want to know what is the language being used in creating a Visualforce Page. Does it using Java, Javascript, HTML or etc etc? Can we randomly choose what sort of language to be used in the system? Or does we able to select which language that most preferable? Or does it only stick to only one language? And I would like if you could re-confirm me the way of doing it. 1) Need to embed the code in the Apex Classes 2) Go to the respective Object and select the Trigger section and embed another code to call the code in the Apex Classes * Am i in the right track?

 

Can someone please guide me on this..

  • October 25, 2010
  • Like
  • 0

hi,

 

I am new to salesforce. please help me out in this ..

 

how to get field values into a list and and display it into a visualforce page?

 

thanks,

-shravan

how to display names of an custom object according to their according to their date creation

 

ex:

var=[select name from billingperiod__c order by ??? ];

 

i want to display names on the order of creation

How would I add in a lookup field to a SOQL query? 

 

More specifically, I'm running a query that returns results based on a lookup field itself.  Actually it's a lookup field to a lookup field, as odd as it may seem, so I can't just type Contact__r.Name for instance, and as far as I know I can't reference anything two levels deep, so Contact__r.Account__r.Name is out, or am I wrong about this? 

 

Or does anyone have any workarounds so I can get the Name field from the Account object from a child of the Contact object and include it into the filtering results of a SOQL call?

 

Example:  [select Id from Child_Of_Contact where Contact__r.Account__r.Name =:'Ted'];  

Hello! I'm new to salesforce and just received my first sophisticated task. Our org is quite plane and I can't find any good examples of Visualforce pages and apex code. Here is my task and if anyone has done something similar, please advice me how to approach it.

 

On Account standard screen I need to place button, let's call it 'Use Account Address'. Clicking on this button should open up VF page that list all the Contacts for this Account. Beside each Contact record there should be check box. There should be also 'Update Selected' button on this page, clicking on which will update all selected Contacts with Account's address and return user back to Account page.

 

Thanks a lot in advance!

Hi All,


DateTime myDate  = DateTime.newInstance(2010,10,10);

 

String strDate = myDate.format('yyyy/mm/dd');

 

does not give expected result '2010/10/10' .Rather it give '2010/00/10' .

 

?

plz let me know where i am wrong or the format method has some  flaw .

 

How to write test class for trigger

am new to apex

 

trigger check on Order__c (after insert) {
Order__c to=trigger.new[0];

Opportunity q=[select id from Opportunity where id=:to.Opportunity__c];
list<OpportunityLineItem> ql=[select id,ListPrice,PriceBookEntry.Name,PriceBookEntry.Product2Id ,Subtotal,TotalPrice from OpportunityLineItem where OpportunityId=:q.id];


for(OpportunityLineItem qli:ql){
Accomodation__c lm=new Accomodation__c();
lm.Price__c=qli.ListPrice;
lm.Name=qli.PriceBookEntry.Name;
lm.Order__c=to.id;
insert lm;
}
}

Hi,

I want to display a link in a VF page using the following code:

 

<apex:outputLink value="{!Hello}">KICCP</apex:outputLink>

 while Hello is a property defined in a class named Kiccp ,here is my VF page header and class Kiccp code:

 

<apex:page standardStylesheets="false" showHeader="false" sidebar="false" controller="Kiccp">

 

public class Kiccp{
public Kiccp(){}
public String Hello {
get{ return Hello;}
set{ Hello=value; }
}

}

 

 

 The result is that the outputlink is my index page! I don't know why!
Could some one tell me  how to initialize the property of a class? in which tag to do this?

Thanks!

 

 

 

Message Edited by ambiti on 03-09-2010 05:53 PM
  • March 10, 2010
  • Like
  • 0

hi Friends,

 i have n output label in which i need to show text scripted in French. i have tried changing the page language and also the user language, but it changes everything that is rendered outside my page.

Any help would be greatly appreciated.

 

example: an output label displaying " interêt" is not getting the desired text.

  • January 07, 2010
  • Like
  • 0

Hi,

 

I have a lookup field called Related_Contact__c on an Opportunity which is a lookup to a Contact record. How can I access the Account for this Contact through the lookup field. I am trying the following, but doesnt seem to work - the error report tells me that there is an "unexpected token: Account"

 

SELECT id, StageName, Sub_Stage__c, Start_Date__c, End_Date__c FROM Opportunity WHERE (Related_Contact__c.Account:=Account)

 

The comparison I am trying to make here is between the Account field of the Related_Contact__c lookup and the Account field on the Opportunity itself.

 

Any recommendations?

Hi,

 

Please guide me for filtering records in pageblocktable using dropdonlist.

 

I tried to implement using following code. But I could not  implement. So Please help me.

 

 

Controller:

 

public class ActivityController 
{

    public PageReference Search() {
    return null;
        }

Task Task;

public Task getTask() {
      if(Task == null) Task = new Task ();
      return Task ;
   }

    Public Task[] getActivities()
    { 
      
   
      return [Select id, subject,activitydate,owner.name,pro__Billable_Hrs__c,pro__Rate_Hrs__c,pro__Billable_Amount__c from Task];
    }


 
}

 

Apex page:

 

<apex:page controller="ActivityController"  >
 <apex:sectionHeader title="Invoice Generate" />

 <apex:form >
<apex:pageBlock >

<apex:pageBlockSection title="Search Task" columns="4" >


<apex:inputField id="Taskstatus" value="{!Task.status}" style="width:150px;"/> 

<apex:commandButton value="Search" action="{!Search}"/>


</apex:pageBlockSection>
<apex:pageBlockSection title="Search Result" columns="1" >
<apex:pageBlockTable value="{!Activities}" var="a" width="750">
  <apex:column >
                        <apex:facet name="header">Select</apex:facet>
                        <apex:inputCheckbox value="{!a.Id}" />
                </apex:column>

<apex:column value="{!a.subject}" rendered="true"/>
<apex:column value="{!a.owner.name}"/>
<apex:column value="{!a.Billable_Hrs__c}"/>
<apex:column value="{!a.Rate_Hrs__c}"/>
<apex:column value="{!a.Billable_Amount__c}"/>
</apex:pageBlockTable>

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

 

Help me asp.

 

Thanks,

Mahendiran

hello all

 

im trying to update a lookup field in the acct with the case id but i keep getting the error variable does not exist, ay help will be appreciate 

 

by the way im new to this apex code and im kind rusty after 10 years i didn’t to programming at all

 

trigger updateAccountWithCase on Case (after insert) {
    set <ID> acc_ids = new set <id> ();
        for (case c : trigger.new)acc_ids.add(c.accountid);
        list<account> acct_to_update = [select id, case__c from account where id in :acc_ids];
            {
            for (account acc: acct_to_update) acc.case__c = caseid;
    update acct_to_update;
    }
}

Hi ,

 

I have  a javascript list button with a lot of validation and stuff for the selected lines.This button creates a new purchase order at the end  and opens the new purchase order form.My code was something like this:

 

..../*validation code*/...

 

--at the end if evrything is ok i have something like this where the fields of the new purchase order form get prepopulated using the address--

 

window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&CF00NR0000000cvG6={!Sales_Order__c.Name}"+
"&CF00NR0000000cvEt={!Sales_Order__c.Default_Warehouse__c}";

 

Now for further development i needed to have a visualforce new form for purchase orders....

So now iam unable to prepopulate this....

the addresses look wierd..


window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&j_id0:j_id1:j_id29:j_id33:test={!Sales_Order__c.Name}"+

 

I need to be able to retain the earlier javascript code because of the complex validations........Can someone please help me with this prepopulating?

hello,

 

Anyone pls tell me how to copy one fields value in another field in salesforce on click of button. i want after filling permant address when i click on button the same will be copied in correspondence address.

 

If anyone know pls help me ot or if having any example code pls post it.

 

Thanks In advance.

  • October 27, 2010
  • Like
  • 0

Hello.  I am trying to write my first Apex test on a very simple trigger...and am having problems. 

 

My trigger (shown below) is fired upon the update of a custom object Customers__c.  The trigger looks at a separate object (WO__c) to see if any record's WOFlag__c field is greater than zero. If so, it updates the respective record's WOFlag__c  value into the CopiedWOFlag__c field in the same record.

 

This trigger works fine.  There are absolutely no problems with it.  My issue is trying to correctly write the test.  The below test code returns the error "Compile Error: Field is not writeable: WO__c.Name".

 

Any thoughts on why I am seeing this?  Any guidance would be greatly appreciated.

 

The test and trigger are listed below.


******** TEST CODE

public class TESTWOFlagGreaterThanZero { 
  
    static testMethod void TESTWOresave(){

        WO__c[] WOtoCreate = new WO__c[]{}; 
        for(Integer x=0; x<200;x++){ 
//using "9999" below since the field name is an auto number.  I am seeing the same "not writeable" error with both

//the "name" field and the "WOFlag__c" field
            WO__c wo = new WO__c(name=9999,WOFlag__c=1); 
            WOtoCreate.add(wo); 
        }  
           
       Test.startTest(); 
        insert WOtoCreate; 
        Test.stopTest();     
    }    
}

 

 


******** TRIGGER
trigger WOFlagGreaterThanZero on Customers__c (after update) {
List<WO__c> WOFlagGtrThanZero =
    [ SELECT j.WOFlag__c
    FROM WO__c j
    WHERE j.WOFlag__c > 0
    FOR UPDATE];

for (WO__c upd: WOFlagGtrThanZero) {
       if ( upd.WOFlag__c > 0 ){
       upd.CopiedWOFlag__c = upd.WOFlag__c;
    }
    }

update WOFlagGtrThanZero;
}

I am very new to SF, but I'm building out a Student Recruiting App for 
my org.  I would love some feedback on the design of this trigger I 
just created.  I'm not sure how much background you need on the data 
structure of the app to provide feedback, but I will give you a basic 
overview. 

 

  • Education Object is detail to to Contact - used to show all schools a 
    prospect has attended.
  • Education has Account Lookup field for link back to School(Account 
    Record) 
  •  Enrollment is Child to Contact - used to Inquiry through graduation 
    for students 
  •  Application is Child to Enrollment 
  •  Document is Child to Application 

I hope that's enough to make sense of it all.  Here is the trigger.  It works just fine, but I 
would love to hear from the experts if this looks like it will scale 
well and any other feedback you are willing to offer. 

 

trigger CreateDocuments on Application__c (after insert) { 

List<Document__c> createdocument = new List <Document__c> {}; 
	for (Application__c app : trigger.new) { 
		List<Contact> c=[SELECT Id,Name FROM Contact WHERE 
		Id=:app.Contact__c]; 
		List<Education__c> ed = [SELECT School__c FROM Education__c WHERE 
		Student__c=:c]; 
		if(app.Recieved_Method__c <> 'Online'){ 
			for(Education__c e : ed){ 
			createdocument.add(new Document__c ( Name = 'Transcript', 
			Application__c =app.id,School__c=e.School__c,Contact__c=app.Contact__c)); 
			} 
		createdocument.add(new Document__c ( Name = 'Recommendation 1', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		createdocument.add(new Document__c ( Name = 'Recommendation 2', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		} 
	} 
try { 
	insert createdocument; 
} 
catch (Exception Ex) 
{ 
system.debug(Ex); 
}

 

Good day. Hye I'm new in this area and i'm about to create a VF page that will create 4 columns in Page Layout.

 

I want to know what is the language being used in creating a Visualforce Page. Does it using Java, Javascript, HTML or etc etc? Can we randomly choose what sort of language to be used in the system? Or does we able to select which language that most preferable? Or does it only stick to only one language? And I would like if you could re-confirm me the way of doing it. 1) Need to embed the code in the Apex Classes 2) Go to the respective Object and select the Trigger section and embed another code to call the code in the Apex Classes * Am i in the right track?

 

Can someone please guide me on this..

  • October 25, 2010
  • Like
  • 0
public class myclass
{
   List<SelectOption> VIEW_DEPARTMENT;

   public List<SelectOption> getDepartments()
   {
      VIEW_DEPARTMENT=new List<SelectOption>();
      VIEW_DEPARTMENT.add(new SelectOption('0', 'All Departments'));

      for (Specialization__c spec : [select Name from Specialization__c]) 
      {
         VIEW_DEPARTMENT.add(new SelectOption(spec.Name, spec.Name));
      }

      return VIEW_DEPARTMENT;
   }
}

Above is the class which is pulling data from database.and same has been used in below page under combo box.I  got ID of the select data in the combox and want to pass that as query string to show a detail page.Can anyone guide me?

 

I knwo we can do if we place as list and user can click on it and the detail section will be displayed with {!currentpage.parameters..}.

 

But I want as sson as the user select the data detail page automatically loads. 

  

<apex:outputText value="Department"/>
<apex:selectList value="{!viewDepartmentName}"id="departmentViews" size="1" required="true">
<apex:selectOptions value="{!DepartmentViewNames}"/>

 

 

 

 

  • October 23, 2010
  • Like
  • 0

hi,

 

I am new to salesforce. please help me out in this ..

 

how to get field values into a list and and display it into a visualforce page?

 

thanks,

-shravan

 

<apex:outputLabel style="">
              <apex:commandButton action="{!add}" value="add"/>
              <apex:commandButton value="Search" action="{!Searchs}" onclick="return SearchClick()"/>
              </apex:outputLabel>

 use css styles like this

 

 <table width="100%">
                  <tr>
                      <td align="center">
                          <apex:commandButton action="{!add}" value="add"/>
                          <apex:commandButton value="Search" action="{!Searchs}" onclick="return SearchClick()"/>
                      </td>
                  </tr>
              </table>

 thanks for your help!

 

 

 

Hello! I'm new to salesforce and just received my first sophisticated task. Our org is quite plane and I can't find any good examples of Visualforce pages and apex code. Here is my task and if anyone has done something similar, please advice me how to approach it.

 

On Account standard screen I need to place button, let's call it 'Use Account Address'. Clicking on this button should open up VF page that list all the Contacts for this Account. Beside each Contact record there should be check box. There should be also 'Update Selected' button on this page, clicking on which will update all selected Contacts with Account's address and return user back to Account page.

 

Thanks a lot in advance!