此内容没有您所选择的语言版本。
Chapter 9. ServiceNow custom actions in Red Hat Developer Hub
In Red Hat Developer Hub, you can use ServiceNow custom actions to fetch and register resources within the catalog.
The custom actions in Developer Hub help you automate the management of records. By using the custom actions, you can:
- Create, update, or delete a record
- Retrieve information about a single record or many records
The ServiceNow custom actions plugin is community-sourced.
To use ServiceNow custom actions, you must first activate the plugin.
Prerequisites
- Red Hat Developer Hub is installed and running.
- You have created a project in the Developer Hub.
Procedure
Add a
packagewith plugin name and update thedisabledfield in your Helm chart as follows:global: dynamic: includes: - dynamic-plugins.default.yaml plugins: - package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-scaffolder-backend-module-servicenow:<tag> disabled: falseThe
<tag>variable is your RHDH application's version of Backstage and the plugin version, in the format:bs_<backstage-version>__<plugin-version>(note the double underscore delimiter).To find the correct image tag for
<tag>:- Look in the RHDH release notes preface for your Backstage version.
-
Locate the plugin version for paths starting with
oci://ghcr.iowithin one of the tables in the Dynamic Plugins Reference guide.
For example, because RHDH 1.9 is based on Backstage 1.45.3, the tag will have the format
bs_1.45.3__<plugin-version>.TipTo ensure environment stability, use a SHA256 digest instead of a version tag. See Determining SHA256 Digests.
NoteThe default configuration for a plugin is extracted from the
dynamic-plugins.default.yamlfile, however, you can use apluginConfigentry to override the default configuration.Set the following variables in the Helm chart to access the custom actions:
servicenow: # The base url of the ServiceNow instance. baseUrl: ${SERVICENOW_BASE_URL} # The username to use for authentication. username: ${SERVICENOW_USERNAME} # The password to use for authentication. password: ${SERVICENOW_PASSWORD}
The ServiceNow custom actions enable you to manage records in the Red Hat Developer Hub.
The custom actions support the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Creates or updates a resource -
PUT: Modify a resource -
PATCH: Updates a resource DELETE: Deletes a resource- [GET] servicenow:now:table:retrieveRecord
Retrieves information of a specified record from a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to retrieve the record from
sysIdstringRequired
Unique identifier of the record to retrieve
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Expand Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [GET]
servicenow:now:table:retrieveRecords Retrieves information about multiple records from a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to retrieve the records from
sysparamQuerystringOptional
Encoded query string used to filter the results
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmSuppressPaginationHeaderbooleanOptional
Set as
trueto suppress pagination header. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmLimitintOptional
Maximum number of results returned per page. The default value is
10,000.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryCategorystringOptional
Name of the query category to use for queries
sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.sysparmNoCountbooleanOptional
Does not run a select count(*) on the table. The default value is
false.The following table describes the output parameters:
Expand Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [POST]
servicenow:now:table:createRecord Creates a record in a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to save the record in
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.The following table describes the output parameters:
Expand Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [PUT]
servicenow:now:table:modifyRecord Modifies a record in a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to change the record from
sysIdstringRequired
Unique identifier of the record to change
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Expand Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [PATCH]
servicenow:now:table:updateRecord Updates a record in a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to update the record in
sysIdstringRequired
Unique identifier of the record to update
requestBodyRecord<PropertyKey, unknown>Optional
Field name and associated value for each parameter to define in the specified record
sysparmDisplayValueenum("true", "false", "all")Optional
Returns field display values such as
true, actual values asfalse, or both. The default value isfalse.sysparmExcludeReferenceLinkbooleanOptional
Set as
trueto exclude Table API links for reference fields. The default value isfalse.sysparmFieldsstring[]Optional
Array of fields to return in the response
sysparmInputDisplayValuebooleanOptional
Set field values using their display value such as
trueor actual value asfalse. The default value isfalse.sysparmSuppressAutoSysFieldbooleanOptional
Set as
trueto suppress auto-generation of system fields. The default value isfalse.sysparmViewstringOptional
Renders the response according to the specified UI view. You can override this parameter using
sysparm_fields.sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.The following table describes the output parameters:
Expand Name Type Description resultRecord<PropertyKey, unknown>The response body of the request
- [DELETE]
servicenow:now:table:deleteRecord Deletes a record from a table in the Developer Hub.
The following table describes the input parameters:
Expand Name Type Requirement Description tableNamestringRequired
Name of the table to delete the record from
sysIdstringRequired
Unique identifier of the record to delete
sysparmQueryNoDomainbooleanOptional
Set as
trueto access data across domains if authorized. The default value isfalse.