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
Gita BorovskyGita Borovsky 

Help for a newbie?

The below code creates a new opportunity record from a custom button.  We also have a checkbox on the opportunity layout called "renewal"  I can't figure out how to edit the code to set the renewal checkbox to true.  Help, please?  Thanks!

 

<apex:page StandardController="Opportunity" sidebar="false" standardStylesheets="true" showHeader="false" id="page" >


<script>
// copyright 2011 SalesLogistix Corporation
// look at the SLX_License_Text file in your APEX Classes areas for details of your license
//
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="/soap/ajax/22.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/22.0/apex.js" type="text/javascript"></script>

<script>

if ('{!Opportunity.CreateRenewal__c}' == "true" && 
   '{!Opportunity.RecordTypeID}' == "012500000009YZoAAM" && 
   '{!$user.ID}' != "005500000016hUGAAY" &&
   '{!$user.ID}' != "005500000017MfAAAU") 
{

window.open('\
/{!Opportunity.Id}/e?clone=1&cloneli=0&\
opp9={!Opportunity.Penultimate__c}&\
retURL={!Opportunity.AccountId}&\
saveURL={!Opportunity.AccountId}&\
00N50000001zTKO=Renewal&\
opp3={!Opportunity.Name}+renewal+for+--->>>+{!year(TODAY())+1}&\&\
opp11=Renewal&\
opp12=90&\
00N50000001z0gp={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/\
{!year( Opportunity.Subscription_End_Date__c )}&\
00N50000001z0gu={!month( Opportunity.Subscription_End_Date__c )}/{!day( Opportunity.Subscription_End_Date__c )}/\
{!year( Opportunity.Subscription_End_Date__c )+1}&\
00N50000002022y=&\
00N50000001z0TR=&\
00N50000001y6OR=&\
','renewal for {!Opportunity.Account.Name}');

//cloneli=1 clones the product line items

// reset the variable back to false
var updater= new sforce.SObject("Opportunity");
updater.Id = '{!Opportunity.ID}';
updater.CreateRenewal__c = 'FALSE';
result = sforce.connection.update([updater]);
}

</script>

</apex:page>