Ask Search:
Good GirlGood Girl 

Record type setting

Hi,

There is a child object named 'stagedetails' under opportunity. The record type of the child object depends on the stage field in opportunity. Our requirement is whenever new opportunity is created, the default record type of 'stagedetails' object should be set, corresponding to the stage field in opportunity. We cant go for manual approach of setting the default record type, since thousands of opportunity is created everyday. So it will be tedious to set the default record type every time. Also before creation of stage detail record itself, the default record type should be same as stage field of opportunity. Let me know if there is any way to implement this requirement.

Thanks,
Malar
Joseph UcuzogluJoseph Ucuzoglu
 Yes you can use Apex Triggers to accomplish this when the child record is inserted.
Good GirlGood Girl
There is one picklist on child object which depends on the record type. Once the opportunity is created itself, the default record type of child should be set corresponding to the field in opportunity. Using trigger it wont work. Since after pressing the save button only, trigger will set the record type. Before pressing save itself it should be set and i want the corresponding picklist values there in child object. Also let me know what method i have to use to set that default value.
Good GirlGood Girl
There is one picklist on child object which depends on the record type. Once the opportunity is created itself, the default record type of child should be set corresponding to the field in opportunity. Using trigger it wont work. Since after pressing the save button only, trigger will set the record type. Before pressing save itself it should be set and i want the corresponding picklist values there in child object. Also let me know what method i have to use to set that default value.
Joseph UcuzogluJoseph Ucuzoglu
 It sounds like you may need to create an Apex controller to extend the bahavior of the object you are trying to pre-set the picklist value for. The Apex Controller would feed a Visual Force page which can then be set up the way you want.

With a few lines of code in Visual Force you can mimic the look of a standard display for your object record.

Getting into Apex Controllers and Visual Force pages is something that can probably best be solved over at the developer boards. http://developer.force.com give the APEX forum there a try and see if they can point you in the right direction.

The Force.com workbook contains chapters on both controllers and visual force.You can find that workbook on this page: http://wiki.developerforce.com/index.php/Force.com_workbook
David SchachDavid Schach
Why, in your business model, does one opportunity have multiple stagedetails records?  
Or is this a workaround for some feature that isn't working right or your users can't see based on license permissions?