Identify which ServiceNow Record Producer was used
Identify which ServiceNow Record Producer was used to create a record
https://www.servicenowguru.com/reporting/identify-servicenow-record-producer-create-record/
ecord producers are a great piece of ServiceNow functionality that allows for the creation of records in any tablevia the standard Service Catalog interface. This capability has been around for quite a while and odds are that you’re already using it in your system to allow end-users to create new incidents…among other things.
Over the years I’ve worked with ServiceNow, I’ve seen several requests to be able to report on or identify the record producer used to create a particular record. This would allow for easier identification of the entry point for record producer transactions. Unfortunately, ServiceNow doesn’t give us a simple way of accomplishing this. Even though there is a record producer ‘Script’ field and a ‘producer’ script object to work with, nothing is built to be able to dynamically identify the record producer used. This means that you’re stuck hard-coding values in a script or adding unnecessary variables to your record producer forms for every single record producer in your system. Read on for a fairly simple solution to this problem!
This configuration can be accomplished in a few simple steps as shown below…
Create a new field to store the value of the record producer used.
We’ll want to store the record producer value on each target record that is created. As such, you’ll need a field to store that value in. I think the best solution is simply to create a new reference field referencing the ‘Record producer’ [sc_cat_item_producer] table named ‘Record producer’ [u_record_producer] on the ‘task’ table. That way, you can have one shared field that will be available to almost everything that you’ll usually use with record producers. If you’ve got additional tables that don’t extend ‘task’, just repeat the same step there as well.
Create a new business rule on the ‘Record Producer [sc_cat_item_producer]’ table.
The purpose of the business rule is to overcome the issue this article is about. We do this by leveraging the record producer ‘Script’ field to populate the ‘Record producer’ [u_record_producer] field created in the previous step. The business rule simply populates the record producer sys_id value into the record producer ‘Script’ field every time the record producer is inserted or updated and then the standard record producer script/creation process takes over and writes the producer Sys ID to the field per normal operations. If you need this to work for non-task tables, you can simply create a duplicate business rule there.
‘Force population of record producer used’ Business ruleForce population of record producer used
Record producer [sc_cat_item_producer]
Before
True
True
True
1100
current.script.indexOf(‘Force population of record producer’) == -1
Name:
Table:
When:
Insert:
Update:
Advanced:
Order:
Condition:
Script:/***There is no dynamic way to record the record producer used so we can force it here
by modifying the script field entry on the record producer. Record producer will be
populated in a reference field on the target record named 'u_record_producer' (which
will need to be created).***/
current. script = current. script + '\n\n\n' + '/***DO NOT REMOVE OR MODIFY THIS SECTION!!! Automatically added by "Force population of record producer used" business rule. \nForces population of this record producer sys_id into the target record for reporting purposes.***/\n' + 'current.u_record_producer = ' + '"' + current. sys_id + '";';
Please note that you will need to manually update every record producer in the system that you want this to work with in order for the producer script to be updated as necessary!
If you’ve done all of the above steps correctly, you should end up with a nicely-populated ‘Record producer’ reference field on each generated record. This value can then be used for reporting or other purposes in your system!
- An ActiveRecord class (XXXXXXXXX) was used but the framework seems not properly initialized. Did you
- no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:myorcl
- How to check which certificate was used to sign my app
- ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was
- Python version 2.7 required, which was not found in the registry
- A SQL Function which used to split string by char
- which must be escaped when used within the value 问题解决
- ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA .
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
- 化零为整WCF(5) - 宿主Hosting(宿主在IIS, Application, WAS, WindowsService)
- The request was denied by service delegate (SBMainWorkspace) for reason: Unspecified.
- 安装win32com报错-Python Version 2.7 required which was not found in the registry 问题解决 .
- Python安装第三方库报错:Python version 2.7 required, which was not found in the registry.
- 安装setuptools时找不到系统中的Python位置:Python version 2.7 required, which was not found in the registry
- 安装第三方库时python version 2.7 required,which was not found in the registry
- python version 2.7 required,which was not found in the registry
- 启动tomcat,出现The Apache Tomcat Native library which allows optimal performance in production environments was not found on the jav
- Nexus启动失败The nexus-webapp service was launched, but failed to start. .
- 安装SP2后,提示"'Preserving/Deleting template record with size","The expected version of the product was not found on the “错误
- 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站。IIS 7