Getting sys_ids of records created from Fluent APIs

Chris Yang
Tera Sage

Hello,

 

I configured an Application Menu via the "ApplicationMenu" fluent API, however, I want to use that object in a "Record" API to create an application module, since there are no dedicate APIs for it. Example code below, see data.application property which expects a sys_id.

 

I read in the docs that Now.ID['id_1'] will resolve in a unique ID, but that's not working. Also tried exporting the output to a variable but no luck. Looking for a solution that I can dynamically resolve the sys_id so that I don't have to build the app first and then retroactively update it.

//menus.now.ts
import { ApplicationMenu, Record } from '@servicenow/sdk/core'

export const appMenu = ApplicationMenu({
    $id: Now.ID['fluent_demo_app_menu'],
    title: 'Fluent Demo App Menu',
    hint: 'hints go here',
    description: 'Descriptions goes here',
    category: '73f1136a3ebc4cfd9f45094e0d01a024',
    roles: ['admin' as any],
    active: true,
    order: 100,
})

Record({
    table: 'sys_app_module',
    $id: Now.ID['my_record_module'],
    data: {
        title: 'My Records',
        application: '2062cef0cdd7483bbb8de89dd723163a',
        // application: appMenu, // not working
        // application: Now.ID['fluent_demo_app_menu'], // not working
        order: 100,
        hint: 'module hint',
        roles: 'admin',
        active: true,
        link_type: 'LIST',
        name: 'x_820676_fludemo_todo_remastered',
        override_menu_roles: false,
        require_confirmation: false,
        uncancelable: false,
    },
})

 

 

 

1 ACCEPTED SOLUTION

Venkat79
ServiceNow Employee
ServiceNow Employee

Hi @Chris Yang,

Thanks for bringing this up.

We are aware of this issue and currently we do not have any alternate solution to it other than what you are doing already.

Our goal is to be able to reference the variables, similar to what you are doing.

 

Record({
    table: 'sys_app_module',
    $id: Now.ID['my_record_module'],
    data: {
        title: 'My Records',
        application: appMenu, // re-use the vairable created earlier
        order: 100,
        hint: 'module hint',
        roles: 'admin',
        active: true,
        link_type: 'LIST',
        name: 'x_820676_fludemo_todo_remastered',
        override_menu_roles: false,
        require_confirmation: false,
        uncancelable: false,
    },
})

 


We are working on improving the experience in future versions of the SDK

Thanks!

View solution in original post

6 REPLIES 6

Venkat79
ServiceNow Employee
ServiceNow Employee

Hi @Chris Yang,

Thanks for bringing this up.

We are aware of this issue and currently we do not have any alternate solution to it other than what you are doing already.

Our goal is to be able to reference the variables, similar to what you are doing.

 

Record({
    table: 'sys_app_module',
    $id: Now.ID['my_record_module'],
    data: {
        title: 'My Records',
        application: appMenu, // re-use the vairable created earlier
        order: 100,
        hint: 'module hint',
        roles: 'admin',
        active: true,
        link_type: 'LIST',
        name: 'x_820676_fludemo_todo_remastered',
        override_menu_roles: false,
        require_confirmation: false,
        uncancelable: false,
    },
})

 


We are working on improving the experience in future versions of the SDK

Thanks!

Thanks @Venkat79 , looking forward to future updates.

 

I see this is only an issue for those working completely off the instance, as the ServiceNow IDE allows for side by side view of both fluent and record form

Moritz4
Tera Contributor

Hi @Venkat79 ,

 

although you are saying that this is not yet possible, the documentation indicates that it is:

https://docs.servicenow.com/bundle/xanadu-application-development/page/build/servicenow-sdk/referenc...

 

Moritz4_0-1725013801204.png

Looking forward to see this feature implemented.

For now, do think it makes sense to update the docs so that they reflect what is actually possible?

 

Thanks

Moritz

Hi @Moritz4,

 

The Record API can be exported to sys_id which works. However, the other fluent APIs are not exportable to sys_id. (haven't tested all but I'm assuming they work the same since it's for specific app files)

 

Fluent APIs exportable to sys_id

  • Records

Fluent APIs not exportable to sys_id

  • Access control lists (ACLs)
  • Application menus
  • Automated Test Framework tests
  • Business rules
  • Client scripts
  • Lists
  • Properties
  • Roles
  • Scripted REST APIs
  • Tables