When our customers have a requirement to create a lot of clauses in the application, they prefer to use an import capability that we have provided. Our import capability is a multi-step process:
- The actual word documents used for the clause content must be available on the application server where the import runs
- A csv to create the clause is first uploaded to create the clause object (clause import)
- A second csv to add the “content” to the clause is imported (content import). This adds the word document to the clause object created in step 2
The issue becomes that each of the clauses created in this way is in a status of “draft”. The customers then need to manually change each of the objects to “approved” in the user interface.
The concept that I have in mind is to: Allow the customer to import another file after adding the content that will result in the clause phase being changed to Approved.
The basic design for this is as follows:
- Add a Boolean Approve Clause extension to the clause object that indicates the clause should be approved. This flag should default to false after the phase has been updated.
- Make the extension read-only in the user interface, via a page customization
- Have a script on the clause validation that indicates the clause should be approved when the flag in #1 is true. The script should set the flag to false at the end.
With this approach, the users could import a new CSV after the content is uploaded with 2 fields in it: Name and the “Approve Clause” Boolean set to TRUE. The import will trigger the validate script which will approve the clause.
Before you start
Ensure that the Company and Enterprise workbooks have been imported into your system as the correct users and that in particular the Company workbook contractgen.Phase phases have been set as these are what the script will be drawing from.
Adding an Extension to the clause object
Logged in as user that is a member of the company the clauses will be for and navigate to Setup –Configuration Extension Definition and create a new extension definition.
In the screen below you can see the two localized values created and the attributes created to enable the desired functionality.

Attribute Internal name | clauseApprovalExt |
Display Name | Clause Approval Extension |
Attribute Description | doc$extension.primary.context.contractgen.clause.clauseapprovalext.desc |
Save this.
Creating the script
Go to Setup – Integration –Script Definition and create a New Script.
Select ‘Import Lifecycle Event’ as we want the script to trigger when an import event occurs.
This is what the fields relating to the script should look like.

::::::::::::::::::CODE::::::::::::::::::
import com.sap.eso.api.contractgen.*;
import com.sap.eso.api.contractgen.phase.PhaseIBeanHomeIfc;
// get the clause phase from the import
logMsg = Logger.createLogMessage(session);
//get the phase ibean for approved
phaseHome = IBeanHomeLocator.lookup(session, PhaseIBeanHomeIfc.sHOME_NAME);
approvedPhase = phaseHome.findUniqueByDisplayName("Approved");
approvedClauseFlag = doc.getExtensionField("CLAUSEAPPROVALEXT").get();
//Check if clause has attachment if not do not attempt advance.
if (hasValue(approvedClauseFlag) && approvedClauseFlag.booleanValue() == true)
{
//Set the Phase to approved
doc.setPhaseObjRef(approvedPhase.getLocalizedObjectReference());
//Uncheck the Clause Approval Extension
doc.getExtensionField("CLAUSEAPPROVALEXT").set(Boolean.FALSE);
}
Save the code and then test the process.