Pseudo-Algorithm for SaveCartAsTemplate
Get the Quote Template, Quote Template Item, Quote Template Item XA, Quote, Quote Item, and Quote Item XA business components.
The Quote Template business component is already positioned on the correct record, as the OrderTemplate method is row-sensitive.
Check the Quote Name input argument. Query the Quote business component to see if there is an existing record with the same name.
If there is, go to step 3;
Else go to step 4.
As Quote Template is a special type of Quote, the Quote business component can be used to search both Quote and Quote Template.
Set Error Message to indicate there is a duplicate name. Check the Return Error Code input argument.
If Return Error Code = N, do not return an error;
Else return an error.
Create a record in the Quote Template business component. Use the Quote to Quote Template field maps to copy fields from the record in the Quote business component to the record in the Quote Template business component. Set the Name to the Quote Name input argument.
Copy each record in the Quote Item business component to the Quote Template Item business component.
Note: As in the OrderTemplate method, make sure the hierarchical relationship is copied correctly by copying each parent record before its child records. Also, copy the child records from Quote Item XA to Quote Template XA.