Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, August 23, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: clone opportunity
christophe
Posts: 4
 
clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Feb 08 11:06 AM
hi,

I'm try to make my first plugin for SlX.
I've to make a plugin for clone an opportunity.
In an opportunity I've N products and I' have to copy theses products to another new opportunity.
also I want to give the choice of user to choice the products that he wants to copy.
i'm using vbscript.
someone can help me ?
Thanks
chris
[Reply][Quote]
Matt Dockins
Posts: 159
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Feb 08 2:37 PM
While not overwhelmingly difficult, that describes a project in and of itself.

This is probably an over-simplification of what you need, but, for example, to clone the products you could use two recordsets, one containing the orginal products that you cycle through and the second that will contain the new products, then you just cycle through the fields property (for i = 1 to rsTarget.FIelds.Count) and assign the values EXCEPT where the field name is opportunityid or oppproductid (i.e. objRSTarget.Fields(i).Value = objRSSource.fields(i).Value

That should atleast get you started. As many of us are consultants here, if we answered more thoroughly to this question we'd almost have to bill you (just kidding)
[Reply][Quote]
christophe
Posts: 4
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Feb 08 2:47 PM
thanks for your answer.
I think that will help me to begin the projet
bye

[Reply][Quote]
Walter Shpuntoff
Posts: 167
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Feb 08 4:58 AM
Some other things to watch out for.
Prices change.
Product availability changes.
So.. when you clone the opportunity you MAY need to
1. update the prices (especially if they have gone up)
2. filter out obsolete products (opportunity_product.product.status <> 'available')

Otherwise, that is guaranteed to be your first round of changes

ws
[Reply][Quote]
christophe
Posts: 4
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Mar 08 5:20 AM
thks
I've a new problem. when I tried to copy the products of a opp1 to a opp2 , I've a sql error:

Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_OPPORTUNITY_PRODUCT'. Cannot insert duplicate key in object 'OPPORTUNITY_PRODUCT'.
The statement has been terminated.


apparently the primary key of the table OPPORTUNITY_PRODUCT is the clustered. but I don't know how I can create a new clustered key.
someone can help me ?
thks

my code is :
id = Application.BasicFunctions.GetIDFor("OPPORTUNITY_PRODUCT")
strSQL = " INSERT INTO OPPORTUNITY_PRODUCT ( " _
& " OPPPRODUCTID , " _
& " OPPORTUNITYID , " _
& " PRODUCTID , " _
& " QUANTITy , " _
& " DISCOUNT , " _
& " PRICE , " _
& " NOTES , " _
& " CREATEDATE , " _
& " CREATEUSER , " _
& " EXTENDEDPRICE , " _
& " STATUS , " _
& " CALCPRICE , " _
& " UNIT, " _
& " PROGRAM, " _
& " PRICEEFFDATE, " _
& " PRICEADJUSTED, " _
& " ESTIMATEDCLOSE, " _
& " ACTUALCLOSE, " _
& " CLOSEPROBABILITY, " _
& " SORT ) " _
& " SELECT "_
& " '" & id & "', " _
& " '" & lnkOpp2.LookUpID & "', " _
& " PRODUCTID , " _
& " QUANTITy , " _
& " DISCOUNT , " _
& " PRICE , " _
& " NOTES , " _
& " '" & getUTCDate() & "', " _
& " '" & Application.BasicFunctions.CurrentUserID & "', " _
& " EXTENDEDPRICE , " _
& " STATUS , " _
& " CALCPRICE , " _
& " UNIT, " _
& " PROGRAM, " _
& " PRICEEFFDATE, " _
& " PRICEADJUSTED, " _
& " ESTIMATEDCLOSE, " _
& " ACTUALCLOSE, " _
& " CLOSEPROBABILITY, " _
& " SORT " _
& " FROM OPPORTUNITY_PRODUCT " _
& " WHERE OPPORTUNITYID = '" & lnkOpp1.LookUpID & "' "

objSLXDB.ExecuteSQL(strSQL)
[Reply][Quote]
Walter Shpuntoff
Posts: 167
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Mar 08 6:36 AM
The Primary Key of Opportunity Product has to be unique.
So.... for OPPPRODUCTID you can NOT use the old value - you have to generate a new one.

This means that your
" SELECT "_
& " '" & id & "', " _
& " '" & lnkOpp2.LookUpID & "', " _
& " PRODUCTID , " _
& " QUANTITy , " _

needs to be more like this:
" SELECT "_
& " '" & application.basicfunctions.getidfor("Opportunity_Product") & "', " _
& " '" & lnkOpp2.LookUpID & "', " _
& " PRODUCTID , " _
& " QUANTITy , " _

hth

ws
[Reply][Quote]
christophe
Posts: 4
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Mar 08 7:40 AM
yes but , I declared at the beginninggof the code the variable id and its value is : application.basicfunctions.getidfor("Opportunity_Product")
normally id = pplication.basicfunctions.getidfor("Opportunity_Product")
thks
[Reply][Quote]
Walter Shpuntoff
Posts: 167
 
Re: clone opportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Mar 08 9:54 AM
Oops... missed that part.

You need to look at the key value (OPPPRODUCTID) it is trying to use and compare that against what's already in the database.

Sometimes you get a more complete error message from the provider if you run the same query through a query tool like QueryExpress, ADOExplorer, etc... QueryExpress is free at www.albahari.com

Either way... you need to look at the data to figure out why it is complaining.

Also... if you are planning on having the data sync, you can't use the sql getdate() function for your date unless you reformat it to ISO.

ws
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/23/2025 6:24:14 AM