
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 09:16 AM
Can anyone advise on what I thought would be a simple configuration.
We have developed a custom form, and one of the fields pulls in the parent reference (in this case the parent project number) when we load a new record. No issues there.
We have another field on the form which is also a reference to the project table. We are trying to populate that field on load with the same parent project value. If I populate it manually I can see that both sys_ids match, but when I run an on load client script to set the value, it fails, even though it is passing the sys_id value of the parent. The script is as follows:
By the way, we have a genuine reason for wanting to reference the same record twice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 09:37 AM - edited 09-10-2024 09:40 AM
Hi @Cirrus,
This should be easily achieved assuming both fields are reference field that point to the same underlying table.
Use the following syntax in your script and adjust accordingly:
(Additionally, make sure your Client Script 'UI Type' field is set to All)
function onLoad() {
var sourceField = g_form.getValue('parent');
if(sourceField){
g_form.setValue('u_provided_to', sourceField);
}
}
Best practice tip - avoid at all times variables with the name 'gr' (A common used variable when calling GlideRecord - this should be avoided at all times)
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 09:33 AM
Hi,
Try this
function onLoad() {
var gr = g_form.getDisplayBox('parent').value
alert("Value + " + gr);//using dispay valyue instead of sys_id
g_form.setValue('u_provided_to', gr);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 09:37 AM - edited 09-10-2024 09:40 AM
Hi @Cirrus,
This should be easily achieved assuming both fields are reference field that point to the same underlying table.
Use the following syntax in your script and adjust accordingly:
(Additionally, make sure your Client Script 'UI Type' field is set to All)
function onLoad() {
var sourceField = g_form.getValue('parent');
if(sourceField){
g_form.setValue('u_provided_to', sourceField);
}
}
Best practice tip - avoid at all times variables with the name 'gr' (A common used variable when calling GlideRecord - this should be avoided at all times)
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 05:52 AM
Thanks Robbie. Did exactly what it needed to to prove the concept and now working as part of an on change script to deliver the requirement