Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Using the Structure classes (e.g. ContractStructure), but when the folder is created, the addFolder method does not return parentId that is necessary for moveItem (and there seems to be no other method in ContractStructure to do it any other way).

  • Using the CalculableLineItemCollectionBuilder (cProcessor/quoteProcessor/raProcessor), but again addFolder returns void so there is no way of knowing the parentId directly.

Solution: def subFolder = qs.createFolder(lineItem.label) folder.items.add(subFolder)

Code Block
//Example for Contracts, use appropriate Structure object for your use case (ContractStructure, RebateAgreementStructure, CompensationStructure, QuoteStructure)

protected ContractStructure createDefaultContractFolderStructure() {
    String myFolderLabel = "Default Folder"
    String myLineItemConditionTypeName = "Default Condition Type"

    ContractStructure contractStructure = new ContractStructure()
    ContractStructure.Item folder = contractStructure.addFolder(myFolderLabel)
    ContractStructure.Item item = contractStructure.createItem(myLineItemConditionTypeName)
    folder.items = [item]

    return contractStructure
}

This code snippet creates a new folder and puts items into it. The trick is not to use moveItem method but do it directly. It works even on empty documents.