Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Default Value using field's data

Daniel Vieira
Tera Expert

 

Hi everyone,

 

When we create a child incident from a parent, some fields (like Parent Incident and Short Description) are automatically populated when the child form opens. I’ve created a custom field called u_parent1, and I’d like this field to also be automatically filled when the child incident form is opened.

 

Specifically, I want u_parent1 to be populated with the sys_id of the caller of the parent incident. This should happen as soon as the child form opens, before the user enters or saves any data.

 

I tried to set this value using the Default Value property in the dictionary with something like current.parent_incident.caller_id.sys_id, but it doesn't work — I assume because that context isn’t available when the form loads. In attachments, we can see an image with that approach.

 

Does anyone know how I could achieve this behavior?

 

Thanks in advance!

 

3 REPLIES 3

Chaitanya ILCR
Mega Patron

Hi @Daniel Vieira ,

 

just put this in the default value

ChaitanyaILCR_1-1750437400268.png

it's (:) not :

 

javascript:current.parent_incident.caller_id

 

 

Also check which is the linking field here is Parent field or Parent Incident field (based on that replace parent_incident with parent if you are using parent)

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

StephenR0086629
Tera Contributor

I’ve handled this in ServiceNow by using a business rule or client script on form load. You can fetch a value from a related field or table and set it as the default dynamically. Just make sure to add proper conditions to avoid overwriting user input. It’s a clean way to streamline form completion without hardcoding values.

Hi @StephenR0086629,

 

I’ve built a solution in Workspace to automatically populate the Source field when creating a new HR Case, based on the parent case's value — but my current approach depends on the URL.

 

When we reach step 2 of the "Create New Case" flow in Workspace, the parent case's sys_id is available in the URL. I use a Client Script and a Script Include to retrieve the parent’s Source value and populate it into the child case. This works — but only because I check the URL to know I’m in step 2.

 

I’d like to find a more robust and upgrade-safe solution that does not rely on the URL. Since URL structures can change in future releases, I want to detect the current step (step 1 vs step 2) through a more stable method — ideally using Workspace context or component state.

Does you know a way to detect which step of the Workspace form flow we’re in, without using the URL?
Or do you have an alternative approach to this scenario?

 

Thanks in advance!