cancel
Showing results for 
Search instead for 
Did you mean: 

How to customize copy function?

mmiriam
Explorer
0 Kudos
322

I added an extension field for sales quotes via sap cloud app studio which should not be copied. How can I achieve that this extension field will be empty when a quote is copied?

Accepted Solutions (1)

Accepted Solutions (1)

dominik_g
Participant

Hello Miriam,

1) add a field to the CustomerQuote BOX on the root node.

//BO Extension
element Z_CustomerQuoteUUID : UUID;

2) Fill the field in the root-Before-Save script with the root node UUID (additional checks are required to make sure that the instance is writable, i.e. not in Status "completed").

3) In root-After-Modify check if the field is different...

//Before Save
foreach(var obj in this) {
     if(obj.Z_CustomerQuoteUUID.content.IsInitial() && !obj.UUID.content.IsInitial()) {
          //todo: writable check
          obj.Z_CustomerQuoteUUID.content = obj.UUID.content;
     }
}


//After Modfiy
foreach(var obj in this) {
     if(!obj.Z_CustomerQuoteUUID.content.IsInitial() && obj.Z_CustomerQuoteUUID.content != obj.UUID.content) {
          //todo: writable check
          obj.Z_CustomerQuoteUUID.content = obj.UUID.content;
          
          //clear your copied extension field here
     }
}

Answers (1)

Answers (1)

ThiagoSarmento
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi mmiriam,

You can try creating a BeforeSave script on the Root node of the Sales Quote BO, which would check if the new document is being created as a copy and then, clear the extension field value.

Best regards,

Thiago

mmiriam
Explorer
0 Kudos

Hi Thiago Sarmento,

Yes, that is what I wanted to do, but how should I check if a new document is being created as a copy?

Thanks,

Miriam