The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

Last week I made a LinkedIn post about the new Utah release feature "Auto-populate a variable". A minor post, though wow so many interest in it! Personally for me this is also the "wow" feature of the Utah release. Such a minor new feature, though potentially a big impact for everyone working on Service Catalog. A lot of use cases for populating Variables through Catalog Client Script (or Catalog UI Policy using the Script fields) can be reverted into using the "Auto-populate" option.


Auto-populate

Let's immediately jump into the Auto-populate functionality. This is what the Auto-populate looks like on a Variable:

 

01.png

 

That's it. A new section, you select the Dependent question which will be a Variable of type reference within your Catalog Item, select the Reference, and choose the Dot walk path. You can actually dotwalk, so you are not limited to only the fields on the Reference table.

 

02.png

 

Actually there's not much more to write on this, the Auto-populate functionality is just so straightforward! Have a Variable of type reference on your Catalog Item, create a new Variable that you want to Auto-populate and fill in the three fields under the new Auto-populate section, and that’s it.

While testing this, the responsiveness looks really good (perhaps even better than GlideAjax with getXMLAnswer), it works also onLoad, and when clearing the dependent Variable the Auto-populated Variable will also be cleared.

 

03.png

 

Note: You might have noticed that the release notes on the ServiceNow Docs mentions this new functionality using Catalog Builder. Though like shown above, Catalog Builder is not mandatory to achieve the Auto-populate functionality.


Pre-Utah

With the Quebec release ServiceNow did introduce "Catalog Data Lookup Definitions". A nice improvement, though just a bit too many steps to get it working. Also Catalog Data Lookup Definitions don't work onLoad.

Other methods to Auto-populate a Variable would be methods like using GlideAjax (ideally with getXMLAnswer), getReference, etcetera. While using GlideAjax works well, it can be a bit complex and is a time-consuming task to develop. Because of this a lot of developers use the lesser method of getReference.
Read more about this subject in one of my earlier articles: Client Side Scripting: Go for GlideAjax (with getXMLAnswer)!

---


And that's it . Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

Independent ServiceNow Consultant
4x ServiceNow Developer MVP

4x ServiceNow Community MVP

---

LinkedIn

Comments
rahulg
Tera Contributor

Hi

 

Thanks for explaining the feature. i have upgraded my instance to Utah, but  still i am not able to see the auto-populate feature in catalog variable. am i missing something. Pleas let me know. thanks in advance.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Have you checked that this is not due to earlier customizations done? And therefore form layout etc not being updated?

 

Kind regards,
Mark

rahulg
Tera Contributor

Hi Mark,

 

Thank you so much. It was due to customization. now I added the section to the variable. Thanks!

Asep
Tera Contributor

Hi @Mark Roethof 

thanks for explaining, this help me a lot

then my next requirement for auto-populating is, need to populate all yellow variable based on/depending selected product model, thanks!

Asep_0-1684137958206.png

 

Iryna13
Giga Contributor

Hi!Thank you for explain!

Suzanne Coffman
Tera Guru

I appreciate the post--sounds like a useful feature.  I have the "Auto-populate" option, but when I tried to use it for the first time, it only listed  17 questions on my request form as being available for the auto-poulation to be dependent on.  Is that because the variable on which it depends is in a custom table?

Suzanne Coffman
Tera Guru

CORRECTION--it listed only THREE of the 17 questions on my request form.

Mark Roethof
Tera Patron
Tera Patron

Hello,

 

Any details that you can share about your setup?

 

Kind regards,
Mark

Suzanne Coffman
Tera Guru

I have a catalog request form that needs to get two fields from a custom table I added in my DEV environment.  The fields I need in the first question is u_facilityjobcode, and the field I need in the second question is u_facilityjobcodename from the same record.  Both are obviously reference type variables.

 

I was able to select the table in the correct table in the Auto-populate tab of the second question (once I used the data table instead of the data load staging table for the first question🙄).  And I selected FacilityJobCodeName in the Dot walk path field.

 

I don't know if it matters, but I also added ref_auto_completer=AJAXTableCompleter,ref_ac_columns=user_name;email,ref_ac_columns_search=true to the Variable attributes on the first field (the one pulling the u_facilityjobcode field).

 

But, when I try the form and select a job code it does not auto-populate the job code name.

 

I have no Catalog UI Policies related to either of those fields except to hide the first (mandatory) field if a third field is selected.

 

Here is the table structure:

TableColumn nameColumn labelTypeReferenceDefault value
u_lawsonjobcodesglobal  Collection  
u_lawsonjobcodesglobalsys_created_byCreated byString  
u_lawsonjobcodesglobalsys_created_onCreatedDate/Time  
u_lawsonjobcodesglobalsys_idSys IDSys ID (GUID)  
u_lawsonjobcodesglobalsys_mod_countUpdatesInteger  
u_lawsonjobcodesglobalsys_updated_byUpdated byString  
u_lawsonjobcodesglobalsys_updated_onUpdatedDate/Time  
u_lawsonjobcodesglobalu_facilitydepartmentidFacilityDepartmentIDString  
u_lawsonjobcodesglobalu_facilitydepartmentnameFacilityDepartmentNameString  
u_lawsonjobcodesglobalu_facilityidFacilityIDString  
u_lawsonjobcodesglobalu_facilitynameFacilityNameString  
u_lawsonjobcodesglobalu_facility_job_codeFacilityJobCodeString  
u_lawsonjobcodesglobalu_facility_job_code_name_job_titlefacilityjobcodenameFacilityJobCodeNameString  
Suganya12
Tera Expert

Variables present in variable set doesnt appear in dependent question field. Any ideas on how to choose those variables?

2022_ServiceNow
Tera Expert

@Mark Roethof Thanks for explaining.

 

I have a doubt. On the form level it is auto-populating and displays the data whereas when we submit the request, in the RITM and TASK the value in the variable is empty. 

Is this functionality not storing the data when we submit the request?

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

It should store the data, so sounds like you have a different issue. If you need help on that, do post a new question on the community so I or others will spot your question and might be able to help.

 

Kind regards,
Mark

Suzanne Coffman
Tera Guru

Per ServiceNow support auto-populate does not work with custom tables.

Noble63
Tera Contributor

Hello,

 

I have tested the new feature "Auto populate" and it's working fine when I'm using it from ServiceNow.
but If I create an item from API, the fileds with auto populate functionality is not working. Fields stay blank.

Do you know if a configuration must be updated at API level for having this auto populate functionality working ?
Thanks

Tehilla Garfink
Tera Contributor

@Mark Roethof  Are there any restrictions for non-roled users viewing the auto-populated variables from the Employee Center? I previously had a GlideAjax script that I replaced with Auto-Populate and now the non-roled users can't see the auto-populated information on the portal.

Himanshu22
Tera Contributor

Hi @Mark Roethof 

 

I am having the same issue that if a user doesn't have access to the other (than the reference field) fields of the table we are referencing, it will not populate the values in the variable for the user.

 

I think @Tehilla Garfink  is having the same issue.

 

@Ankur Bawiskar  :Any ideas?  

GK15
Tera Contributor

The reason why it is not working for users with role snc_external is ACL for this API "Get Dynamic Value"

/api/sn_sc/servicecatalog/variables/{sys_id}/dynamic_value 

 

ACL is "Scripted REST External Default" which reject access for all users with role snc_external.

GK15
Tera Contributor

And ServiceNow opened problem: "Auto population of the variable of service catalog is not working for external user" - fix is planned for 

WashingtonQ2-2024
Marlon Dale
Tera Expert

I have the auto-populate configured and working correctly. Only issue is I can't set the variable to read only either by checking Read only in the variable, via onLoad Client Script, or via UI Policy.

Rich Dennis _CC
Tera Contributor

An issue I found is that Auto-populate doesn't work when the question/variable to be populated is hidden by UI Policy.

 

Scenario:

question/variable #1 = user table reference

question/variable #2 = yes/no question

question/variable #3 = location table reference set to auto-populate from question/variable #1, but hidden by UI Policy unless question/variable #2 is "yes"

In this scenario question/variable #3 does not get populated because it isn't visible at the time that question/variable #1 is populated. By comparison, Catalog Client Script "On Change" will populate it, even when hidden by UI Policy.

 

EDIT:

Turns out the issue wasn't auto-population. There was a UI Policy that had "Clear the variable value" set to "true". Changing that to "false" allowed the auto-population value to persist between question/variable #3 being visible and/or hidden.

monicaroger
Tera Contributor

@Himanshu22 & @Tehilla Garfink Did you find a solution? I have the same issue.  Auto-Populate doesn't work for my internal users who do not have support roles (like ITIL)

 

kumar junior11
Tera Contributor

@Mark Roethof i did the same steps you mentioned above, but 

Auto-populated variable is visible on Form Level but not in RITM and Task

 

Mike Grimm
Tera Contributor

Does this feature work cross-scope? I built a variable set in the Customer Service application with a Contact Name variable that references the the Contact [customer_contact] table, an Account variable that references the Account [customer_account] table, and a couple of string fields to display information that I'm using the Auto-Populate feature to populate. The Record Producer that the variable set is associatedWhen I (admin) select a Contact from the catalog item form, there are no issues and the fields populate correctly. When I impersonate a Contact, I receive an error message and none of the fields auto-populate. Has anyone else experienced this issue?

InfamousSpork
Tera Contributor

I really like this option, however, I do wish there was an addition to it. I wish there were an option to auto-populate but still allow the user to change to a different option if needed. Or if the field to populate from is blank to still list the available options to choose from.

Dave65
Tera Contributor

Hi Mark

Thanks for your article. I have found an issue though.  I created 2 reference fields and set up the Auto-populate and the fields were populated correctly. I then needed to hide/show those fields based on the content of one of them. Even though the fields on the Record Producer were populated correctly, when my OnLoad script read them, they were blank.
I finally wound up using some JS code in the Default value tab to populate the fields and then my script was able to read the correct value.
So, it seems like the order of execution is such that the Script OnLoad script ran before the Auto-populate.
The end result is that you can't use the Auto-populate feature if you need to test the content of a field during OnLoad.

ColtonL
Tera Explorer

Hello all,

 

Has anyone else had any issues with using the new Auto-populate feature on dates?  I'm having some issues with it not taking into account a user's date format preference.  So when it fills in the date on the form, it uses the system default instead of the user's preference.  But the form expects the user's preference format, so it will throw an error on submit.

Nick43
Tera Contributor

For me the auto populate variable does display but when the request is submitted it does not persist and value is empty on RITM

JStockel
Tera Expert

I've tried to apply so that the field is displayed via Form Layout, but it will not appear... Any ideas what I'm missing?

Harithavalli
Tera Contributor

Thanks for bringing this to us, very helpful feature.

Version history
Last update:
‎07-30-2024 10:18 AM
Updated by:
Contributors