You need to sign in to do that
Don't have an account?

Pre-Populate Contact Info in New Opportunity? (OportunityContactRole)
Hello,
I am trying to create an opportunity off of a custom object which has Contact as a lookup. The custom button uses as S-control to pre-populate the Opportunity fields such as name, stage, etc. i am unable to populate a ContactOpportunityRole object for the Opportunity by passing in values for the contact, role, and isPrimary.
Is there a way to do this or are we doomed to doing 2-step data entry for this Opportunity creation? I know that the Opportunity ID is required for OpportunityContactRole creation so it makes sense that the object can't be magically created just by passing the Contact Info into the "New" edit screen, especially since it is not visible on the edit screen and they are query parameters...
This is what I tried, the regular Opportunity fields are pre-populated correctly:
Thanks!
Sara
I am trying to create an opportunity off of a custom object which has Contact as a lookup. The custom button uses as S-control to pre-populate the Opportunity fields such as name, stage, etc. i am unable to populate a ContactOpportunityRole object for the Opportunity by passing in values for the contact, role, and isPrimary.
Is there a way to do this or are we doomed to doing 2-step data entry for this Opportunity creation? I know that the Opportunity ID is required for OpportunityContactRole creation so it makes sense that the object can't be magically created just by passing the Contact Info into the "New" edit screen, especially since it is not visible on the edit screen and they are query parameters...
This is what I tried, the regular Opportunity fields are pre-populated correctly:
Code:
<script language="JavaScript"> function redirect() { parent.frames.location.replace("/006/e—retURL=%2F{!Author__c.Id}&opp3={!Author__c.Name}&primary0=1&role0=Business User&contact0_lkid={!Author__c.ContactId__c}&contact0={!Author__c.Contact__c}") } redirect(); </script>
Thanks!
Sara
So for example, we are creating one type of opportunity off of an existing opportunity. I have written an S-control/button to pre-populate the new opportunity record, and have pulled the contact information in, but how would that information be passed to the trigger when it's only in a query parameter? Unfortunately there is no such field type as "Hidden" which would solve this problem.
Here's my s-control which prepopulates the new opportunity from the existing opportunity and opportunitycontactrole objects
(Please feel free to suggest a cleaner way of doing this if possible):
But I am not clear on how my trigger would access the contact information (which is in the OpportunityContactRole of the parent Opportunity, and a query parameter in the URL). I think the only possibility is to have the parent opportunity ID pre-populated into a lookup field in the new opportunity and work backwards from there?
Thanks so much!
Sara
If you'd like to learn more about triggers, look up the Force.com Cookbook; it's got some good example code.
Yes, i am familiar with triggers, I am actually a backend Java/Oracle developer so that part comes *much* more easily to me than the Javascript side!
Specifically I just wasn't sure if there was a mechanism of passing info from the client to the server side (trigger) other than the obvious solution of having it stored in a field in the record for the backend to pull from.
We need for each opportunity to have the contact mapped to it automatically upon creation and short of sticking the contact ID in a read-only field for the trigger to run off of, I don't see how to make it work. Especially since we are creating opportunities off of: contacts, other opportunities, and custom objects.
The downside to that solution is that you are replicating data - a field with the contact iID and an opportunitycontactrole with the same info. then it because important to keep both of those in sync, which requires more trigger work... sigh.
We may just decide to have a contact field on the opportunity and ignore the opportunitycontactrole all together since for us each opportunity can only have one contact. I just hate to ignore a commonly used construct for compatibility reasons.
Ideas?
Thanks!!
Sara
Tucker seems to have made a hidden field on the opportunity called conid which is populated by a query parameter he passes in. That was pre-trigger time so he has some sort of backend code that then reads that field upon save and does the creation.
If only there was a field type of "Hidden" available! that would make everything much easier.
Thanks again,
Sara