function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
APKAPK 

s-control within a custom button that creates a new opportunity with a specific record type

All:
 
I am sure that someone has already done this within their instance, but if you could volunteer your expertise I would appreciate it. Here's what we are trying to do:
 
We have created a custom button associated with a specific opportunity record type. We would like this button to create a new opportunity that copies the account owner and opportunity over to the new opportunity, but assigns a different record type. Ideally, the detail edit screen for the new opportunity would automatically pop. I am trying to use an s-control to do this, but am currently stuck. 
 
Ideas or examples would be greatly appreciated,
 
APK
Greg HGreg H
This can be accomplished by passing the necessary parameters in the URL from the page where your button is located to the edit page for opportunities.  In the URL string you would have to include the parameter for your account id (&opp4_lkid={!Account.Id}) and the parameter for your recordtype selection (&RecordType=012300000000XXX). A sample of the url could be:
Code:
/006/e?retURL=%2F006%2Fo&RecordType=012300000000XXX&cancelURL=%2F006%2Fo&ent=Opportunity&opp4_lkid={!Account.Id}

In my example, I am passing other parameters just in case the user decides to cancel the opportunity creation after they already get to the opportunity edit screen.
 
Hope this helps,
-greg
APKAPK

Thanks Greg!  That helped a ton!

I now need to control for the internal scroll bar and tabs.  I've been doing some research on Iframes, and what other folks have done to try to control for this (as well as what SFDC has published on the matter), and it looks like most people have only found limited success. 

Am I just spinning my wheels?

Greg HGreg H

Because the sControl is loaded into an iframe on the salesforce.com page you can call out that specific iframe and resize it using a pretty simply piece of code.  This function is below:

Code:

//resizes the frame holding the sControl to make up for odd dimensions
function resizeFrame() {
 var sframe = parent.document.getElementById("itarget");
 sframe.style.height = document.body.scrollHeight+"px";
}

 

Simply place this code within a script tag in your sControl and then call the function as the last line in any JavaScript you execute on the page.

Hope this helps too,
-greg