Post Agreement Revise
  • 14 Feb 2025
  • Dark
    Light

Post Agreement Revise

  • Dark
    Light

Article summary

Purpose

Allows you to run a script to execute custom actions when users revise a published agreement.

Setup

Upload the script for Post Agreement Revise.

For details about uploading and configuring Groovy scripts, read Upload a Groovy script.

Binding variables

In addition to the common binding variables, the following binding variables are available for this extension point.

Variable name

Class

Description

salesItemsTree

SalesItemsTree

Represents the Quote object associated with the agreement under negotiation. Contains functions you can use to query and modify the header and its line items.

agreement

Agreement

Represents the agreement. Contains functions you can use to query and modify the agreement.

This variable can’t modify data. Use it only to retrieve information from the agreement.

agreementHeader

AgreementHeader

Represents the AgreementHeader object. Contains functions you can use to query and modify the agreement and its line items.

This variable can’t modify data. Use it only to retrieve information from the agreement.

accountInfo

AccountInfo

Represents the AccountInfo object. Contains details of the linksAgreementAccount.

accountPFRecords

List<PartnerFunctionRecord>

List of PartnerFunctionRecord objects. Represents partner function records of the linked account.

sourceAgreementPFRecords

Collection<PartnerFunctionRecord>

Collection of PartnerFunctionRecord objects. Contains a list of objects representing partner function records of the source Quote object associated with the agreement under negotiation.

Expected output

No output expected.

Script execution

A script that you upload for this extension point runs automatically when users revise a published agreement. If you use the salesItemsTree variable in the script to modify the agreement data, the system applies changes to the Quote object associated with the agreement under negotiation.

If no script is uploaded for this extension point, the system creates agreement revisions without additional action.

Sample script

import com.imc.vocabulary.Schema
import com.imc.iss.groovy.agreements.Agreement
import com.imc.iss.groovy.agreements.AgreementHeader
import com.imc.iss.groovy.agreements.AgreementLine
import com.imc.iss.groovy.salesitem.SalesItemsTree
import com.imc.iss.groovy.salesitem.SalesItemNode

// Script Execution: SalesItemsTree Started
System.out.println('Script Execution: SalesItemsTree Started')

// Get the quote title and URI
def quoteTitle = salesItemsTree.getQuoteDataAttributeValue(Schema.objectName.getUriAsString())
System.out.println('Agreement Quote URI: ' + salesItemsTree.getQuoteURI())
System.out.println('Agreement Quote Title: ' + quoteTitle)

// Set the updated quote title with prefix
salesItemsTree.setQuoteDataAttribute(Schema.objectName.getUriAsString(), quoteTitle + ' - SalesItemsTree')
System.out.println('Added prefix SalesItemsTree in Quote Title')

// Script Execution: AgreementHeader Completed
System.out.println('Script Execution: AgreementHeader Completed')

// Doubling the Policy Value at All Levels of a SalesItemNode: Started
System.out.println('Doubling the Policy Value at All Levels of a SalesItemNode: Started')

// Iterate through each SalesItemNode and double the policy value
for (SalesItemNode salesItemNode: salesItemsTree.getChildren()) {
    doublePolicyValue(salesItemNode)
}

// Method to double the policy value of a SalesItemNode
void doublePolicyValue(SalesItemNode salesItemNode) {
    def position = salesItemNode.getSalesItemDataAttributeValue(Schema.salesItemPosition.getUriAsString())
    def policyValue = salesItemNode.getSalesItemDataAttributeValue(Schema.agreementPolicyValue.getUriAsString())
    salesItemNode.setDataAttribute(Schema.agreementPolicyValue.getUriAsString(), 2 * policyValue)
    System.out.println('Policy Value at ' + position + ' : ' + policyValue)
    // Recursively double the policy value for child nodes
    List < SalesItemNode > salesItemNodes = salesItemNode.getChildren()
    for (SalesItemNode child: salesItemNodes) {
        doublePolicyValue(child)
    }
}

// Doubling the Policy Value at All Levels of a SalesItemNode: Completed
System.out.println('Doubling the Policy Value at All Levels of a SalesItemNode: Completed')

// Accessing all AgreementLine URIs
System.out.println('Accessing all AgreementLine URIs')

// Iterate through each AgreementLine and access its URI
for (AgreementLine agreementLine: agreementHeader.getAgreementLines()) {
    accessAgreementLines(agreementLine)
}

// Method to recursively access all AgreementLine URIs
void accessAgreementLines(AgreementLine agreementLine) {
    System.out.println('URI: ' + agreementLine.getAgreementLineURI())
    List < AgreementLine > agreementLines = agreementLine.getAgreementLines()
    for (AgreementLine child: agreementLines) {
        accessAgreementLines(child)
    }
}

// Script Execution Completed
System.out.println('Script Execution Completed')

// Return the agreement object
return agreement


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.