You need to sign in to do that
Don't have an account?
Sascha Löffler
Copy Relationship to another Parent
I need your help for the following requirement:
We want to copy contact relationship from a Custom Object to another record of that Object, using visualforce page.
Objects:
I didnt find anything to come out of that so i hope you can give me some hints.
We want to copy contact relationship from a Custom Object to another record of that Object, using visualforce page.
Objects:
- Group__c
- Contacts
- Group_Relationship__c (Junction Object between Group & Contacts)
I didnt find anything to come out of that so i hope you can give me some hints.
It sounds like you are on the right track though.
It is not entirely simple to "make" a custom lookup on a visualforce page for an arbitrary record.. certainly not using the standard <apex:inputfield> tag anyway.. you might be able to do some jiggery pokery with the record in memory (ie. the Group that launched the page) to get a lookup field with a Value referenced to itself, or a new "shim" field on the Group that is itself a lookup to "Group__c" and then nick the value out of that when it is selected... or you will have to write your own quick interface to allow the user to populate a text value and then send that back to some SOQL to try to find a single match..
There are some neat examples of doing things like that all over the internet, including "search as you type" boxes with a bit of jQuery etc. - allowing you to make quite a nice UI if you want.
Once you have the new Group__c selected, you will need to fire an action back to your page.. this can be a straight up "Submit" button on your form, or you could use @RemoteActions to Ajax yourself a form submission. Simplest is to just submit the form and put an onSubmit back to a method in your Apex.
The target method will then look something like:
That should move all the Contact relationships via the junction object to the new group Id; which hopefully is what you are after?
Don't forget a unit test or two! Sorry I couldn't be more helpful on the UI aspect, it really depends on what you want to do there; and there are so many options it would take days to type up.