cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CPQ 2.0 - OnItemCopied event (global script)

tomdevilder
Explorer
0 Likes
459

In “Before add to quote” event of my configurable product I create a unique id ("PA_UniqueId) an put it in an attribute (if attribute is empty). In a global script on the event "BeforeItemAdded" , I read that attribute and add it to a Quote Item Custom field (UCF_UniqueId)

Now when I copy that Item on the Cart, this attribute and user custom field are copied along. What I want to do is to fill them with a new unique id (because otherwise it is not unique anymore)

This I try to do in a global script with event "OnItemCopied". There I get the product from the "context.CopiedItems" and fill the attribute with a new unique id. I do the same for the user custom field of the copiedItem. The Orginal Items I leave as it is.

My question now is, how can this be saved ? Because the values are not stored (although if I debug them at the end of the script, the new values are visible in the attribute / user custom field)

Next info was found in the HELP

User copies item in quote
          Execute item action : Copy
                Performing calculations on copied item
                Build number of items for product types
                Copying product configuration
                Copying item attachments
          Saving copied items
  After copying products in quote event trigered
 context:  CopiedItems : IEnumerable<IQuoteItem>
                 OriginalItems : IEnumerable<IQuoteItem>
                 Quote : Instance of type: Quote2
                Get item column values
  Before quote rendering event trigered
context -> Quote : Instance of type: Quote2

As far as I can see the product / quote item is not saved anymore. So what is the use of the "After copying products in quote event" to be triggered ? Some more info on how this works, and what the use is would be nice. 

Who can tell me what I'm doing wrong  and how I can solve my problem ?

 

 

The problem is solved... I found the solution... Not able to answer to your comments 😞

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

eric_silva
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi @tomdevilder ,

As you commented in your post it's resolved, I'll provide this solution in this answer.
But please feel free to write how you resolved the issue in case anyone has the same issue in the future!

All the best,
Eric Silva

Answers (0)