+ Start a Discussion

Help with Trigger to Fill Custom Field

Is it possible to develop a trigger so that a custom field that is filled with the aggregate of entries in a field of a related list? For example, for our contacts we have a related list of projects - each of these falls under 1 of 7 themes.  We would like to create a custom field that is automatically populated with all of the themes on any of the related projects, and then be able to add additional themes manually. Very new to cloud development so any help is appreciated!


This looks complecated. My assumptions about your question.


You have created contacts and each contact is associated with list of projects means that contact is common for all of your projects. you have list of projects in to that related list section of contact. Now you want to have custom field that can populate all the themes for any of the project or all the project? 




1) on what basis we need to fill that custom field?

2) do u have all the projects in 1 sand box?


According to my understanding 


you have single sandbox , you need to create Theme object and you need to create vf page on the top of this object and you need to develope functionality in which you can select themes from local and store it in to theme object. or maintain all the list of thems in to some static resource and use it from static resource.


Now you need to establish lookup relationship between each project and theme object and assign the them to specific project. or you can ccustomize with 1 object and estabblish relationship between your contact , theme and project object and configure form this one object it will reflect in to all the places..


As you ask is it possible to update in custom field i think it will be difficult as considering your scenario. Yes updation of field is possible using trigger or by using formula mield but according to me it will not help in your scenario.


It will be great if you could provide more inputes in details.






We want a custom field that can populate for all of the themes for all of the projects, and then we would like to be able to manually add additional entries if necessary. 


The custom field will represent research interests for the researchers - these interests will include any topic that they have worked on in the past, but may also include additional topics. 


We would also like to fill other custom fields in the same way for other related lists - for example, for staff involved on a project, we would like to have a field for all the researchers involved on that project (contained in a custom field).


We have all the projects under a custom object that is linked to contacts, so each contact does have a related list of projects. 


It could potentially work in the case of themes to create an additional object but what about the case of research staff and primary researchers, both of which we would like to remain under contacts?


Thanks for your help


Is it possible to fill a custom field from a custom report? 


I am not sure .. :(



You would do this on a trigger of the Project object. In an After-(Insert/Update) trigger, you would get the Contact and make the adjustment to your "theme" custom Field.


Make sure that the trigger is written for a large number of Projects begin updated at once (bulkified).