You need to sign in to do that
Don't have an account?
anja
cross object access with visualforce
I have a parent object "admission form"
it has two related lists:
"survey 1"
"survey 2"
we would like to add a single field on survey 1 that concatenates 14 fields from survey 2
my difficulty is in accessing the data from survey 2
tried using a formula field but ran into difficulty with # of unique relationships per object (vlookup)
now trying visualforce, possibly with controller
any ideas?
Your trigger should be like this
This trigger is only work correct for single record, for bulk it will not give perfect results, just check for single if it work I will help you to make it for bulk as well. let me know if any issues in it.
All Answers
Sounds like you need a trigger.
The above gives you the main idea, however you will need to modify it to fit your environment. Also, it will only populate the field when a survey 1 is inserted or updated, so you will have to consider that.
Good Luck!
this is very close, however I am getting the following error and not sure what I am doing wrong:
Error: Compile Error: Loop variable must be of type SOBJECT:Discharge_Survey__c at line 5 column 13
trigger concatFields on Discharge_Survey__c (before insert, before update){
List<ID> ids = new List<ID>();
for (ID thisID: trigger.new)
{
ids.add(thisID);
}
List<Clinical_Pathway__c> survey2s = new List<Clinical_Pathway__c>([Select Patient_Admission_Readmission__c, Fluid_status_assessment__c,Fluid_management_orders__c
from Clinical_Pathway__c
where ID IN: ids]);
for (Discharge_Survey__c s1: trigger.new)
{
for (Clinical_Pathway__c s2: survey2s)
{
if (s1.Patient_Admission_Readmission__c == s2.admission_form__c)
{
s1.CHFFluid_Management_Pathway__c = s2.Fluid_status_assessment__c + s2.Fluid_management_orders__c;
}
}
}
}
Your trigger should be like this
This trigger is only work correct for single record, for bulk it will not give perfect results, just check for single if it work I will help you to make it for bulk as well. let me know if any issues in it.