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
jmaskell123jmaskell123 

Clone Opp Renewal

Hi can anyone please help me with this as i have posted it several times with no responce, it is really bugging me as i am so close and i am sure it is something really simple.

I have this code that creates a clone of an opportunity, it is a java script button on the opportuntiy page layout

 

// 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 ); }

 

but the problem i am having is that this only works when a date is manually imput into the code.

what i want it to do is clone the opportuntiy but for 1 year later.

i think the following line needs to be changed:

 

newOpp[0].StageName = "Prospecting";
newOpp[0].CloseDate = new Date(2099, 0, 1);
newOpp[0].Type = "Renewal"

 

But whatever i put i cannot get it to work

 

Can anyone please help me on this as i am so close to getting a prefect renewal button.

 

Thanks very much to anyone that can help me

 

 

Jake Maskell

Message Edited by jmaskell123 on 09-04-2009 08:13 AM
GoodGrooveGoodGroove

Jake,

 

I can not help you directly with your java script problem, but if you like, I can share a Visualforce Page and it's controller (fully tested), which we use to create renewals.

 

Rgds

Sebastian 

jmaskell123jmaskell123

Hi Sebastian,

 

That would be great if you could

 

Kind Regards

 

Jake 

GoodGrooveGoodGroove

Just have to generalize the logic, because we have some specific features implemented by default, like

  

- Renew the Opportunity Line Items 

- Clone Partners

- Clone Contact Roles

- ... 

 

so you can select what should be processed.

 

Will take some time, I'll post  a code share link.

 

Sebastian 

jmaskell123jmaskell123

Hi Sebastian,

 

thats exactly what we are looking for "Renew the Opportunity Line Items " is even better i diddnt know that it could be done.

 

Hope to see the code soon.

 

Many Thanks

 

Jake 

GoodGrooveGoodGroove

As i promised here's the link to the code share project

 

http://developer.force.com/codeshare/apex/ProjectPage?id=a0630000004uCARAA2 

 

feel free to modify 

 

 

Rgds

Sebastian 

Message Edited by GoodGroove on 09-30-2009 04:04 PM
jmaskell123jmaskell123

Hi Sebastian,

 

Thats very kind of you, but unfortunatly i am revicing an error when trying to install the packages

 

http://img70.imageshack.us/img70/486/screensx.jpg

 

take a look at the screenshot above.

 

Hope you can help

 

Thanks

 

Jake 

GoodGrooveGoodGroove

You need to activate Opportunity Record Types, to install this package.

 

Do you have the Force.com IDE running? I'll also upload the code to code.google.com so you can modify it.

 

Rgds. 

jmaskell123jmaskell123

Will this work with professional eddition as that is the version we are using.

 

then previous post was when I was testing it in developer edditon.

 

take a look at this screenshot please this is the error I am receiving

 

http://img41.imageshack.us/img41/6365/42232989.jpg

 

Thanks

 

Jake