You need to sign in to do that
Don't have an account?
Relating different custom objects based on some specific field
In general database structure, we relate 2 tables by specifying some column as a foreign key.
In my application I have created 2 custom objects "Donor" and "DonLogin". Donor contains all basic information like 'donorID', name, address.. While DonLogin have login information i.e.. fields like username, password etc. I want to create 1-1 relationship between Donor-DonLogin. DonorID is AutoNumber. Can I relate these 2 objects using DonorID?
I am creating object records through visualforce page and controller class. I have managed to create records for both objects through same controller. But I want to take some field of 'Donor'(especially DonorID) and want to insert its value in 'DonLogin'. It is giving me error saying 'DonorID is not writable field'. What should be done so that DonorID will be editable field? I want to refer this system generated value in other custom objects as a reference key. How to do this?
Master-detail relationship type does not allow any specific field to select as reference key. How can I set some field as a connection between 2 objects?
Hi,
In Salesforce.com the following are possible.
If you want to related Donor with DonLogin, create a field in DonLogin as a Lookup reference to Donor object. This will automatically does what you want. But this allows you to create more than one record in DonLogin for the same DonorId. Since you do not want that, control it using ur visual force page.
Best Wishes,
Thank you for your reply!!
I tried as per your solution.
But it is giving me error. I am posting here visualforce page and controller class code. Will you please help me to solve this?
Visualforce page 'DonorRegi1'
Controller class code 'DonorRegiCon1'
It is showing following error:-
Visualforce Error
System.StringException: Invalid id: donlog10
Error is in expression '{!mysave}' in component <apex:page> in page donorregi1
Class.DonorRegiCon1.mysave: line 28, column 1
It is giving error for [ dl.Donorobj__c=d.Name; ] statement.
I tried [ dl.Donorobj__c=d; ], but it is not working.
Will you suggest some solution?