+ Start a Discussion
icbomber38icbomber38 

S Control - Change Opportunity Layout on Close Won

I've been getting some help from one of the SFDC people (which has been great compared to previous experiences).  We're trying to archive Won opps and they gave me some java for an s-control that was designed to do the same thing for cases:
 
<script language="JavaScript">

function redirect() {

var retURL = escape("/{!Opportunity_ID}");

parent.frames.location.replace("/{!Opportunity_ID}/s?retURL="; + retURL +"&RecordType=012300000000AA3" )

}

redirect();

</script>
 
I went ahead and created a new page layout (basically making all the field read only) but, as a complete novice, I have no idea what to do next.  She recommended I come here for more help - any guidance would be greatly appreciated.  The code in RED makes no sense to me - is that being grabbed from the record when the s-control is executed?
 
Thank you,
 
Lee
Ron HessRon Hess
The name=value pair in red is trying to change the record type of the opportunity / case to a new record type.

you will have to edit the actual ID to match the record type id to one that you want to end up with when the custom link is finished running.

you can get this ID from your system, but you need to have the record type defined, and the new page layout specified as the layout which will appear when records have this record type.

to get this ID , go to a record, click [change] next to the record type field on the layout, then look in the address bar for the ID, it should be there somewhere, you may have to add the record type field to one of your layouts.
icbomber38icbomber38

Ron - I went ahead and set everything up.  I click on the Custom Link ARCHIVE I created and I get this text framed in the SFDC tabs:

<script language="JavaScript"> function redirect() { var retURL = escape("/00630000002epxM"); parent.frames.location.replace("/00630000002epxM/s?retURL="; + retURL +"&RecordType=012300000004tKm" ) } redirect(); </script>

Here's the code I have for the S Control:

&lt;script language=&quot;JavaScript&quot;&gt;

function redirect() {

var retURL = escape(&quot;/{!Opportunity_ID}&quot;);

parent.frames.location.replace(&quot;/{!Opportunity_ID}/s?retURL=&quot;; + retURL +&quot;&amp;RecordType=012300000004tKm&quot; )

}

redirect();

&lt;/script&gt;

Am I missing a character somewhere?  Needless to say my Opportunity is not "archived".

Thank you for your help.  My boss is all over me to get this going but he forgets I am not a programmer.

Lee

Ron HessRon Hess

i think the

/s?

should be

/e?

and you will need added to the redirect string.

Code:

&save=1


 

 

Ron HessRon Hess

if it helps here is the entire URL you are trying to construct, ( to pass to reload or redirect() )

in this case it's for a lead converting to a new record type

Code:

/00Q30000000Ydei/e?retURL=%2F00Q30000000Ydei&RecordType=012300000000gpA&save=1


 
/e  specifies the Edit page for the object ( leads because the 00Q  identifier)

so 00Q30000000Ydei  is the lead i started on, this appears again in the retURL

012300000000gpA is the new record type i want the object to have

save=1 causes the edit page to go ahead and save

 

Message Edited by Ron Hess on 05-18-2006 04:00 PM

icbomber38icbomber38

Thanks again Ron but still not geting anywhere.  I think the original code my SFDC contact sent me has a bunch of extra characters that are giving me problems.  I've looked at a bunch of code designed to do similar things and they all seem much shorter without all the &amp and &quot stuff.

I'm not a programmer at all so it could just be that simple.  Unfortunately I don't have anyone else to go to internally that know code and SFDC.

Lee

ScotScot
Lee,

The code you had, with &quot, etc. had escaped values for characters such as ? and ".
What you want to enter into the actual scontrol window is the un-escaped versions.

An scontrol which should work would look like:

Code:

<script language="JavaScript">; 
parent.frames.location.replace(
   "/{!Opportunity_ID}/e?retURL=/{!Opportunity_ID}" + 
   "&RecordType=0120000000000AC&save=1" ) 
</script>

(I also removed some other unneeded portions).
(You'll need to use your RecordType in place of my AC one).

Message Edited by Scot on 05-19-2006 04:06 PM

icbomber38icbomber38
Scott - thank you!
 
As fate would have it I now have another issue.  When I click the S Control link on the opportunity I end up with:
 
Insufficient privileges.
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

Click here to return to the previous page.
 
I think I'm in over my head on this - any ideas?  I'll get my privileges bumped up and see what happens.  Seems to me like anyone should be able to hit the S control and execute (we have others that are set up like that).
 
 
ScotScot

The priviledge error probably refers to the operation being performed in the sControl, not the the ability to run the sControl.

In this case, it's probably the ability to edit the opportunity or to save it with the different record type.

I'd try manually changing the opportunity to that record type through the UI - you'll probably get the same error that way.

icbomber38icbomber38

Well - I have sales manager access and I can edit any opportunity.

Forgive my ignorance, how does one change the record type through the UI?

Thank you very much.

ScotScot
Presuming that the record type is visible on the page layout ...
You'll see something that looks like:
 
     Opportunity Record Type   Standard [Change]
 
To change the record type, you click on the Change link.
 
You can find this in the online help by searching for "change record type"
 
icbomber38icbomber38

Scot - I finally have it all set up properly.  I did away with the java and went with your idea to manually change the record type.  As I expected there's one more thing - how do I lock down the Stage of an opportunity (read only) on this record type?

I'm going to post this on the Best Practices board as well to see if there's anyone who can help me.

Thank you,

Lee