The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Jon G Lind
ServiceNow Employee
ServiceNow Employee

The good old core UI isn't going anywhere, and sometimes you may want to create something directly on the platform instead of formulating Fluent now.ts files.  Perhaps you have a colleague who isn't into working the same way that you do in the IDE (maybe they use the core UI or a builder or App Engine Studio) but you want to incorporate their changes.

 

The good news is that items added outside of the SDK or IDE get added to your fluent project. The other good news is that you can use these outputs for supported types to "migrate" them into first-class fluent objects. I'll show you how.

Generated

Some types have Fluent plugins that directly support their authoring in Fluent and using TypeScript to constrain and guide their development, e.g. Tables and Business Rules.  Others do not, such as Script Includes or UI Policies.  Either way, whenever a change is made to the source file a corresponding representation is created in the "/src/fluent/generated" folder with a file name in the format table_name_sys_id.now.ts

 

Supported types use the Record API and output results similar to the following:

JonGLind_0-1730149262660.png

Supported types have a similar generated .now.ts file but use the API, for instance this business rule using the BusinessRule plugin:

JonGLind_1-1730149543855.png

But what if I want to take control?

You may want to take control of these generated files so that you can organize it in your preferred structure and allow yourself to edit it as Fluent code.

 

Well, now that you have a version in Fluent it's super easy. 

1. Just copy the entire contents of the file then delete it.

2. Create a now.ts file, or edit an existing file in the /src/fluent folder.  E.g. you may want to put all files related to a certain table in one location, or organize all business rules in a single file.  In my example I am going to add it to my existing index.now.ts.

3. Verify that you already have the necessary import statements at the top of the file and if not add them.

4. Delete the copied import statement and the "export default" prefix on the type definition line.

JonGLind_2-1730150122111.png

Save the file and rebuild and you should be good to go--any changes made here will reflect in the platform and any changes made in the platform will automatically update here.

 

Note: You may also convert script fields

If you would like you can mark script fields in the Fluent file with a template literal so it's easier to read.  The only downside is that if it's ever edited in the platform again it will get escaped and overwritten.

JonGLind_0-1730321722433.png

 

A note on Now.ID

Those who are getting used to using "Now.ID" to manage sys_ids may notice that I "hard coded" the sys_id that was pasted in as a simple string.  If you wish to you can replace that with a call to the Now.ID array which is managed in keys.ts, but I personally am perfectly happy to use a sys_id since it's already been created by the platform for me.  I've been doing it for so long that it feels natural and as long as it's unique it will work fine.

Version history
Last update:
‎10-30-2024 01:56 PM
Updated by:
Contributors