Global Functions

Global functions are useful for code that multiple objects want to share. You use global functions when you write Groovy scripts using the expression builder in Application Composer.

Some global functions are delivered with your cloud service, ready for your use. Or, you can define new global functions.

This topic:

  • Provides a list of some predefined global functions that are provided in Application Composer.

  • Explains how to define new global functions.

For more information on global functions, see the Groovy Scripting Reference guide. See "Defining Utility Code in a Global Function" for details on using global functions in your scripts.

Examples of Predefined Global Functions

This table lists the global functions that are provided for use in Application Composer.

Important: These global functions are not available for selection in the expression builder. Instead, to use these functions, manually type the function name into your script, using the full package name as described in the below table.

Global Function

Description

encodeURL()

Returns a translated URL-encoded format string using the specified encoding scheme.

To use this function, use its full package definition: oracle.apps.crmCommon.extensibility.content.adf.data.context.DynamicURLUtil.urlEncode(value, encodingStyle)

getCurrencyRate()

Returns the currency conversion rate from one currency to another on the specified date. The first argument is the From currency code. The second argument is the To currency code. The third argument is the conversion rate date.

To use this function, use its full package definition: oracle.apps.crmCommon.extensibility.content.adf.data.util.ExtensibilityGroovyUtil.getCurrencyRate()

getEndDate()

To use this function, use its full package definition: oracle.apps.crm.service.svcMgmt.fwk.model.util.SvcPublicDueDateutil.getEndDate(startTime, duration, durationUnit, scheduleId)

getObjectURL()

Returns a URL of the classic object detail page for a particular row.

To use this function, use its full package definition: oracle.apps.crmCommon.extensibility.content.context.ObjectURLGroovyWrapper.getObjectURL(entityName, primaryKey)

getResourceUserPartyId()

Global method to get the partyId for a given username.

To use this function, use its full package definition: oracle.apps.cdm.foundation.publicModel.common.util.HzGroovyUtil.getResourceUserPartyId(userName)

getSession()

Note: The usage of this global function is deprecated.

getTrustToken()

Returns the Oracle Platform Security Services trust token. The token is valid for 4 hours.

To use this function, use its full package definition: oracle.apps.fnd.applcore.common.SecuredTokenBean().getTrustToken()

getUserPartnerCompanyId()

Returns the partner company's party_ID for the logged-in user, if the user is a partner user.

To use this function, use its full package definition: oracle.apps.cdm.foundation.publicModel.common.util.HzSessionUtil.getUserPartnerCompanyId()

getUserPartyId()

Returns the logged-in user's Party_ID.

To use this function, use its full package definition: oracle.apps.cdm.foundation.publicModel.common.util.HzSessionUtil.getUserPartyId()

See Classes and Methods Supported in Groovy Scripts.

getUserPrimaryBU()

Returns the logged-in user's primary business unit.

To use this function, use its full package definition: oracle.apps.cdm.foundation.publicModel.common.util.HzSessionUtil.getUserPrimaryBU()

getUserProfile()

Note: The usage of this global function is deprecated. Instead, use the SecurityContext global function to get the user profile.

getUserRootResourceOrgId()

Returns the organization_ID for the logged-in user's organization hierarchy root resource organization.

To use this function, use its full package definition: oracle.apps.cdm.foundation.publicModel.common.util.HzSessionUtil.getUserRootResourceOrgId()

omnichannelCancelWork()

To use this function, use its full package definition: oracle.apps.crm.service.omnichannel.service.ExtnOmniChannelUtil.cancelWork( context, objectName, objectId, reason )

omnichannelPropertyChange()

To use this function, use its full package definition: oracle.apps.crm.service.omnichannel.service.ExtnOmniChannelUtil.propertyChange( context, objectName, objectId, oldValues )

sendNotification1()

Sends a notification to all enabled delivery methods. The delivery methods, message text, and recipients can be configured on the notification preferences page. If notification preferences for the trigger exist, then the values in the preferences take precedence. The first argument is the ADF object. The second argument is the messageText. The third argument is the partyId.

To use this function, use its full package definition: oracle.apps.crm.service.notifications.util.NotificationUtil.sendNotificationFromGroovy(context.object, context.source, context.newValue, context.oldValue, messageText, recipientPartyId)

sendNotificationSimple1()

Invoke from an object function Groovy script to send a notification to the Bell channel. The first argument is the ADF object. The second argument is the messageText. The third argument is the partyId.

To use this function, use its full package definition: oracle.apps.crm.service.notifications.util.NotificationUtil.sendNotificationSimpleFromGroovy(context.object, context.source, messageText, recipientPartyId)

sendNotificationSimple2()

To use this function, use its full package definition:

oracle.apps.crm.service.notifications.util.NotificationUtil.sendNotificationSimpleFromGroovy(context.object, context.source, requestParameters)

serviceRegion()

To use this function, use its full package definition: oracle.apps.crm.service.svcMgmt.srMgmt.util.SvcUtil.getServiceRegion( partyId )

Defining Global Functions

To define a global function:

  1. In Application Composer, navigate to the Common Setup pane, which displays in the regional area.

  2. Click Global Functions.

    Note: You must be in an active sandbox.
  3. On the Global Functions page, click New.

  4. Specify the global function name and a return value.

  5. Enter a description and example of the global function.

  6. Optionally check the Privileged check box.

    If this function might run on an object where the runtime user has no privileges to create or update records, then check this box. Users without access to an object's data can still run this function at runtime, with full access. See "Server Scripts: Explained" for more details on privileged scripts.

  7. Optionally specify one or more typed parameters that the caller will be required to pass in, when the function is invoked.

  8. Specify the body of the function.

  9. Validate and save your function.