The CreatorCon Call for Content is officially open! Get started here.

Clear all values of a multi-user variable of type requested_for

IosifH
Tera Contributor

I am building a catalog item that includes a multi-user variable of type 'requested_for'. The checkbox 'enable_also_request_for' is enabled for this variable. There is a a catalog client script (onChange) that clears the value of requested_for when another variable changes. Here is the script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    g_form.clearValue("requested_for");
}

The current behaviour  is that when 'remove_or_add_checkbox' changes value only the first row/user from requested_for is being cleared (where snowflake.reporting user appears).

The expected behaviour is that I'd like all users (including admin, data management & AWS clouddiscovery) to be cleared when 'remove_or_add_checkbox' has another value (e.g. when switching from 'add' to 'remove'). Please see the attached screenshots for reference.

IosifH_0-1761229043994.pngIosifH_1-1761229059906.png

 

 

Has anyone experienced this issue or knows how to clear all selected users in a multi-user variable via client script? Thanks in advance!

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@IosifH 

both the variables have same name and hence the issue and it's clearing only the 1st one.

the 2nd variable is list collector and give it some other name and enhance your script as this and it will clear both

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    g_form.clearValue("requested_for");
    g_form.clearValue("listVariableName");// give your variable name here
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

I'll try to reproduce. Maybe its a weird thing of the requested_for variable type.

 

It's not what Ankur is mentioning in his reply. Since its about the requested_for variable type.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn