function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sonaperthsonaperth 

Grabbing other fields of object from lookup button.

hi guys, im very new in salesforce, i have just done reading the force.com_developer guide.

and i got a question.

 

if i have 2 objects:

1. course, fields = id, name, duration.

2. class, fields = courseName(course lookup), duration, startDate, endDate

 

and when i create a new class, after i choose the course using the lookup button,

i want to grab the duration of the course as well and put it in the class.duration field before clicking the Save button, just doing it on the interface level if i may say.

can anyone help me?

or maybe a suggestion which guide should i read next after the first one?

 

thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 
CcroninCcronin

Hi Sonaperth,

 

Np. have a look at this http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=15543

 

The bottom post should be enough to get you coding a solution. :D

 

  

 

ps Anand, he posted it on the Visualforce Developer Board so i assume he is looking for a VF solution.  Plus he also mentioned 'put it in the class.duration field before clicking the Save button' which i took as he wanted to see it on the screen before he clicked the save button which to me says AJAX (correct me if i am wrong sonaperth) 

All Answers

CcroninCcronin

Hi-ya Sonaperth,

 

The Guide you are looking for is the Visualforce Developers Guide, specifically the Section 'Using AJAX in a Page' around p38.

 

Basically you will have an extended controller or a custom controller that will use ajax to pull data from the Course Record, then populate that to a class record.

 

All the best!

sonaperthsonaperth

hi Ccronin,

thanks for the reply, ive tried to read the AJAX section, havent read the whole book tho.

 

im still confuse how exactly to pull the data out from the course object, could you please give me some example or code?

 

is it possible to bind the course object in the custom controller for the class page?

 

thanks again! much appreciated.

Anand@SAASAnand@SAAS

Not sure why you are using visual force here (unless it's for UI reasons). You can have a simple cross-object formula to push down the course.duration to class.duration. The assumption is that class.duration will be the same as course.duration. You can also think about doing this via a Workflow field update. 

 

It would help to understand what you are really trying to do with Visual force to better help you with your question. 

 

 

CcroninCcronin

Hi Sonaperth,

 

Np. have a look at this http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=15543

 

The bottom post should be enough to get you coding a solution. :D

 

  

 

ps Anand, he posted it on the Visualforce Developer Board so i assume he is looking for a VF solution.  Plus he also mentioned 'put it in the class.duration field before clicking the Save button' which i took as he wanted to see it on the screen before he clicked the save button which to me says AJAX (correct me if i am wrong sonaperth) 

This was selected as the best answer
sonaperthsonaperth

hi Anand,

thanks for the reply.

if its possible to do it before clicking the save button, id like to know how to do it using the formula field.

 

ok thank you very much Ccronin.

sonaperthsonaperth

hi guys,

can anyone give me more example?

i have tried to search around the forum, and tried different approach to get it done, but it is still not working.

thanks in advance, and again sorry for my newbness coz i have just learned this thing for less than 2 weeks.