Skip to Content

Adjusting the phase of an imported clause through scripting.

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:

  1. The actual word documents used for the clause content must be available on the application server where the import runs
  2. A csv to create the clause is first uploaded to create the clause object (clause import)
  3. 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:

  1. 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.
  2. Make the extension read-only in the user interface, via a page customization
  3. 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


Display Name

Clause Approval Extension

Attribute Description


 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.



// 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

//Uncheck the Clause Approval Extension

Save the code and then test the process.

You must be Logged on to comment or reply to a post.
  • Hi Paul,
    As always, your blogs help combat some pressing enterprise situations
    Read it, Tweeted it and posted it on Linked in
    Hope people will benefit from this feature
  • Hello Paul,

    I was trying to upload the CSV to create the Clause, but i am having problems and i get the next error when i try tu upload the Clause:

    # Failed: object 1: Error executing script: Sourced file: inline evaluation of: ``import*;  import . . . '' : null. [STANDARD_ATTRIBUTE_ID].

    Have you have this problem before?


    Best Regards.