[Bug] Unable to create domain record using Now.ID then use that referance during record creation #91
-
|
I am attempting to create Demo data in a domain separated environment by creating a DEMO domain and then creating customers for that domain: The DEMO domain creates as expected: const domainTableName = 'domain';
//Demo Domain Record
Record({
$id: Now.ID[`${domainTableName}1`], //Returns sys_id 'ff3a82c360584d3cbd1b8018f857a2ae'.
$meta: { installMethod: 'demo' },
table: domainTableName,
data: {
name: 'DEMO',
active: true,
type: 'Customer',
description: 'Domain for demo customers and demo data',
parent: '774190f01f1310005a3637b8ec8b70ef', //Top domain sys id
primary: false,
}
})I then proceed to create 2 customer records: const customerTableName = 'customer_account';
//Customers
Record({
$id: Now.ID[`${customerTableName}1`],
$meta: { installMethod: 'demo' },
table: customerTableName,
data: {
name: 'Parts Unlimited',
sys_domain: Now.ID[`${domainTableName}1`], // Returns string domain1
}
})
Record({
$id: Now.ID[`${customerTableName}2`],
$meta: { installMethod: 'demo' },
table: customerTableName,
data: {
name: 'UniCo',
sys_domain: 'ff3a82c360584d3cbd1b8018f857a2ae', // Inserts the correct reference
}When i manually insert the Sys_ID the field reference creates as expected. Has anyone seen this or found a workaround? I am quite new to this ecosystem. I have placed sanitized code in this repository: https://github.com/u173487/Snow_Domain_Sep_Demo |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You can't use Now.ID as a variable like that, use the record you created. I dont know what import { domainRecord1 } from "../domainrecord.now.ts" //<-wherever you created this import it
const recordOne = Record({
$id: Now.ID['customer_account_1'],
data: {
sys_domain: domainRecord1.$id
}
}) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.

You can't use Now.ID as a variable like that, use the record you created. I dont know what
domainTableName1 is but if its a record you created elsewhere you can use it like a variable on the sys_domain field if you want its sys_id that gets generated.https://servicenow.github.io/sdk/fluent/now-id-guide#dont-use-nowid-outside-of-key-creation-for-a-record