+ Start a Discussion
jmaskell123jmaskell123 

Renewal Opp

Hi Does anyone know how to edit the following code to add 365 days to the close date of the new opp.

 

 

// Copyright 2008 BrightGen Ltd - All Rights Reserved try{ {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} // ** EDIT THIS QUERY TO LIST THE FIELDS YOU WANT TO COPY ** var result = sforce.connection.query("Select o.Type, o.StageName, o.Description, o.Amount, o.AccountId From Opportunity o WHERE o.Id = '{!Opportunity.Id}'"); var newOpp = result.getArray("records"); // Reset the Opp Id and reset fields to default values newOpp[0].Id = ''; newOpp[0].Name = "Renewal - {!Opportunity.Name}"; // ** EDIT THESE FIELDS TO SET DEFAULT ANY VALUES ** newOpp[0].StageName = "Prospecting"; newOpp[0].CloseDate = new Date(2099, 0, 1); newOpp[0].Type = "Renewal" var saveResult = sforce.connection.create(newOpp); if (saveResult[0].getBoolean("success")) { newOpp[0].id = saveResult[0].id; alert("Renewal Opportunity Has Been Created."); } else { alert("Failed to create clone: " + saveResult[0]); } // Refresh the page to display the new oppportunity window.location = newOpp[0].id; } catch (err) { alert (err.description ); }

 

 

Thanks if anyone can help as this is important in our company.

 

Jake

Message Edited by jmaskell123 on 08-10-2009 03:41 AM
Siddhesh KabeSiddhesh Kabe
 newOpp[0].StageName = "Prospecting"; 
newOpp[0].CloseDate = new Date(2099, 0, 1);
newOpp[0].Type = "Renewal"

You should change it here. Look for date-functions in VF page developer guide. Its very easy.
jmaskell123jmaskell123

Hi Thanks

 

But i cannot find a solution on the developer guide ?

 

any other ideas.

 

Thanks 

jmaskell123jmaskell123

Please I really need some help with this.

 

so close to getting it to work.