You need to sign in to do that
Don't have an account?
dotneteric
Creating an OpportunityTeamMember record when changing Opportunity ownership
Hello. I am hoping someone can help me out. I created an S-Control that changes the ownership of an opportunity, we call it "referring the opportunity". The problem we are having is in keeping the team members of the opportunity when the ownership is changed via the S-Control. The team members get deleted when the ownership is changed. If I could at least add the previous owner as a team member after ownership has changed (which in turn is after the team members get deleted), we could bear with it. But, I can't even do that because after the ownership of the opportunity changes, and the logic that creates the OpportunityTeamMember record runs, the logged in user doesn't have rights to create the record because they are not the owner of the opportunity anymore.
How can I change the owner of the Opportunity without losing my team members? If there is no way to prevent losing the team members, how can I at least create one team member record (the person who is the previous owner; who is referring the opportunity to the other person)?
Thanks in advance.
-E.R.
just thinking out loud, why not "saving" in your scontrol the team members changing the owner and repplaing team mebers after that
Regards
Message: insufficient access rights on cross-reference id
Message Edited by dotneteric on 11-07-2006 05:36 AM
Above I have pasted the simplified form which salesforce.com displays when manually submitting an owner change. The "keep sales team" field (id=p10) is the one you wish to leverage. It should then be possible to populate the fields in this form and submit it within an app.
I was able to get my form to submit to the salesforce.com change ownership page. The reason why it wasn't submitting is because I had document.editPage.submit() instead of document.editPage.save.click(). I didn't really want to do it like that since a change in salesforce will cause the functionality to break, but it is a short term solution until the winter or subsequent release when we can develop a solution that we have more control over.
The code now does the following:
1) Modifies custom fields of the opportunity record
2) Adds the current owner to the team members of the opportunity
3) Submits my form to the salesforce.com page which changes the ownership of the opportunity (there is a field that when set to 1 maintains the team members)
Here is what I took from the saleforce.com form and what I added:
document.getElementById("p2_lkid").value = beanUser.get("Id");
........
document.editPage.save.click();
........
function SetFormValues() {
document.getElementById("id").value = OPPORTUNITY_ID;
document.getElementById("retURL").value = "javascript:window.top.location.replace(\\\'/" + OPPORTUNITY_ID + \\\');";
document.getElementById("save_new_url").value = "/setup/own/entityowneredit.jsp?retURL=%2F" + OPPORTUNITY_ID;
}
.......
<form action="/setup/own/entityowneredit.jsp" id="editPage" name="editPage" method="POST">
<input type="hidden" name="id" id="id">
<input type="hidden" name="retURL" id="retURL">
<input type="hidden" name="save_new_url" id="save_new_url">
<input type="hidden" name="p2_lkid" id="p2_lkid">
<input value="R" type="hidden" id="p11R" name="p11" /> <!-- gives previous owner read access to the opportunity -->
<input value="1" type="hidden" id="p3" name="p3" /> <!-- email notification -->
<input value="1" type="hidden" id="p10" name="p10" /> <!-- keep team members -->\
<input value=" Save " style="visibility:hidden;" class="btn" type="submit" title="Save" name="save">
</form>
Works rather nicely.
Message Edited by dotneteric on 11-08-2006 05:47 AM
Message Edited by dotneteric on 11-08-2006 05:49 AM
That's good stuff... I'm going to bookmark that one. Glad you got it working.