g_form.setValue() pulls a blank value instead of the called value

Venjamin
Tera Contributor

Hey, team. I have a basic question, and I feel like I'm probably missing something super basic / simple. 

 

I threw a simple script together: 

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;

}

var autoPop = g_form.getReference('system_display_name', autoFill);


function autoFill(autoPop) {
g_form.setValue('business_system_owner',autoPop.u_approvers_g3);
g_form.setValue('business_it_system_owner',autoPop.u_approvers_g2);
}

}

 

 

The u_approvers_g3/g2 are reference fields on the table where system_display_name is pulling. In theory, once they enter the value for system_display_name, it should add the two approvers to their specific fields. Instead, it populates an entirely blank value, and while the information button exists, if you click it, it shows that there is no display value available. 

I tried to drill down deeper and added u_approvers_g3.user_name and that didn't work. I feel like I am just missing some piece, or a definition. I've modeled this script after another one that I use to populate user data, but it doesn't work here, while it works normally on any other place the user info is required. 

 

Any help would be appreciated! 

1 ACCEPTED SOLUTION

Ok, and so is the reference fields for the business system owner and it system owner pointing to the same table as the u_approvers_g2/g3?

Because if the alert is showing a sys_id...then the getReference callback is working...now its down to an issue with that sys_id not working correctly in the business system owner and it system owner field...which makes me think the table is not the same...thus when the sys_id is trying to be set in there...it's not equaling a valid value...so instead...you see a "blank" with the info icon showing...but that is usually meaning it's "undefined"...so something is there...it's just not defined and so it shows blank with an info icon that goes to no record.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hi,

Can you add alert statements to your script to see what it says you're getting back?

A few things need to be correct to ensure a good outcome:

1) Business System Owner and Business IT System Owner need to be referenced to the same table that u_approvers_g3/g2 are referenced to on that other table.

2) That record that you're trying to get values from...should have values for those 2 approver fields so you know that it is working

Try to troubleshoot on your end by trying...alert statements...

So like:

function autoFill(autoPop) {
alert("Business System Owner: " + autoPop.u_approvers_g3);
g_form.setValue('business_system_owner',autoPop.u_approvers_g3);
alert("Business IT System Owner: " + autoPop.u_approvers_g2);
g_form.setValue('business_it_system_owner',autoPop.u_approvers_g2);
}

Also, you could try to end the opening function before this callback kicks off...meaning:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var autoPop = g_form.getReference('system_display_name', autoFill);
}
function autoFill(autoPop) {
alert("Business System Owner: " + autoPop.u_approvers_g3);
g_form.setValue('business_system_owner',autoPop.u_approvers_g3);
alert("Business IT System Owner: " + autoPop.u_approvers_g2);
g_form.setValue('business_it_system_owner',autoPop.u_approvers_g2);
}

So those alert statements should be reporting back sys_ids?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Sorry for the delay getting back to you - yes, the alert triggers and displays the sys_id.

Ok, and so is the reference fields for the business system owner and it system owner pointing to the same table as the u_approvers_g2/g3?

Because if the alert is showing a sys_id...then the getReference callback is working...now its down to an issue with that sys_id not working correctly in the business system owner and it system owner field...which makes me think the table is not the same...thus when the sys_id is trying to be set in there...it's not equaling a valid value...so instead...you see a "blank" with the info icon showing...but that is usually meaning it's "undefined"...so something is there...it's just not defined and so it shows blank with an info icon that goes to no record.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

You were right! The reference table was user, but I was having the system pull against the table that was pulling against the user table, and just assumed it would work. Thank you very much, sir.