Auto Populate Not Working if Dependent Question Has a Default Value

jmiskey
Kilo Sage

I am creating a Record Producer (though I suspect the same would be true for a Catalog Item) where I have three fields at the beginning:

- Requestor

- Requestor Email

- Requestor Department

 

These should all be auto-populated when the Record Producer is opened on the Service Portal to be filled out.

 

For the Requestor field, I have a default value of:

jmiskey_0-1730466149082.png

 

Then, I set up the Requestor Email variable to be Single Line Text, with the Auto Populate tab filled out like this:

jmiskey_0-1730465533382.png

 

And I set up the Requestor Department variable to be a Reference field, with the Auto Populate tab filled out like this:

jmiskey_1-1730465640325.png

 

The goal is when you open the form from the Service Portal, all three of these fields will be automatically populated (I ultimately want to make them all Read-Only so the Requestor cannot change their values).

 

The issues is when you open up the form, it populates the Requestor with the correct value, but does not pre-populate the other two fields.  It only populates them if you change the Requestor value (so it does not appear that  this "Auto Populate" feature works "On Load" - it behaves more like "On Change" of the Dependent field).

 

Is there an easy way to get these fields to behave properly, and all 3 automatically populate when the form loads, without having to go back to the old method of using Catalog Client Scripts?

 

This auto-populate seems like a nice feature, if we could get it to work properly!

 

Thanks.

 

 

1 ACCEPTED SOLUTION

Figuring it might be the Order Guide (as I know that has a lot of limitations), I removed the Auto Populate features for those two fields, and created a Catalog Client Script that runs On Change of my "Requested Name" field that has a callback function that looks like this:

 

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

	var req_for = g_form.getReference('requestor_name', setUserFields);
	function setUserFields(req_for){
		g_form.setValue('requestor_email',req_for.email);
		g_form.setValue('requestor_department',req_for.department);
	}
   
}

 

This works as expected, so I think I will just go with this option.

 

Thanks for looking into it though!

View solution in original post

17 REPLIES 17

I am very familiar with expected behavior, and did just now validate in a Washington DC instance. What happens if you change Requestor Name to another user, and then back to you? I assume you have an email and department on your user record.

Yes, I have information in those cells, and see it populate when I change to someone else and then change back to myself.

 

BTW, we are doing this in Xanadu.  Can you test it out on Xanadu?

 

Also, is there any sort of Configuration setting that could be affecting this?

Same behavior in Xanadu (Patch 1, Hotfix 2a). I am not aware of any configuration setting that could be affecting this. Did you check the console and JavaScript log?

Here is the release we are on: 

Build tag: glide-xanadu-07-02-2024__patch2-09-25-2024

 

I just thought of two things that might be impacting this:

- This is creating a record against the SAFe Epic table

- This Record Producer is part of an Order Guide

 

I know that certain things do not work the same in Order Guides.  Could that perhaps be the issue?  If you add your example to an Order Guide, can you get it to work?

Figuring it might be the Order Guide (as I know that has a lot of limitations), I removed the Auto Populate features for those two fields, and created a Catalog Client Script that runs On Change of my "Requested Name" field that has a callback function that looks like this:

 

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

	var req_for = g_form.getReference('requestor_name', setUserFields);
	function setUserFields(req_for){
		g_form.setValue('requestor_email',req_for.email);
		g_form.setValue('requestor_department',req_for.department);
	}
   
}

 

This works as expected, so I think I will just go with this option.

 

Thanks for looking into it though!