- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 05:58 AM - edited 11-01-2024 06:02 AM
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:
Then, I set up the Requestor Email variable to be Single Line Text, with the Auto Populate tab filled out like this:
And I set up the Requestor Department variable to be a Reference field, with the Auto Populate tab filled out like this:
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 08:31 AM - edited 11-01-2024 08:32 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 06:40 AM
Hi @jmiskey - Your desired behavior is the expected behavior. Are there any client scripts executing onLoad? Are there any errors in the console?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 06:47 AM
No, nothing like that.
So it is expected behavior that the Auto Populate fields do NOT populate if the Dependent field is being populated by a Default Value calculation? What is the logic behind that? Doesn't seem to make sense to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 06:54 AM
No, when the form is loaded, your three fields Requestor, Requestor Email, Requestor Department should be auto-populated. I assume the disconnect between "Requestor" in your post and "Requestor Name" in your screenshots is a typo.
Try setting up a brand new record producer with just those three fields, configured as described, and see if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 06:59 AM
Yes, sorry that is a typo. I have named the field "Requestor Name".
I have already done what you suggested, which is why I posted this question. I started with a brand new Record Producer with only these three fields, set-up exactly as I described in my initial post. When I open the Record Producer on the Service Portal, it shows my name in the "Requestor Name" field, like it should, but the other two fields are blank. If I changed the "Requestor Name" field at that point to anyone else, it populates those two fields!
Did you try it yourself to see if you have this behavior too?