We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Catalog

NehruV
Kilo Contributor

Provide the UI policy and client script in the attached the excel sheet.

2 REPLIES 2

Aditya_hublikar
Mega Sage

Hello @NehruV ,

 

I think this is your Requirnment sheet .

 

To auto populate group based on item_name following onChange Client script will work :

 

Configuration

  • Type: Catalog Client Script

  • Applies to: Catalog Item

  • Script type: onChange

  • Variable name: item_name

 

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

// Clear existing value
g_form.setValue('group', '');

if (newValue == 'Curd') {
g_form.setValue('group', 'Group A');
}
else if (newValue == 'Water bottle') {
g_form.setValue('group', 'Group B');
}
else if (newValue == 'Icecrim') {
g_form.setValue('group', 'Group C');
}
else if (newValue == 'Lights') {
g_form.setValue('group', 'Group C');
}
else if (newValue == 'Cool drinks') {
g_form.setValue('group', 'Group D');
}
}

 

 

2)to show group field if item_name is not empty 

 

UI Policy Setup

  • Applies to: Catalog Item

  • Condition:If item_name is not empty 

 

  • Variable: u_group

  • Visible:  True

  • Mandatory:  False

  • Read Only:  True

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya,

technical Consultant

 

 

AndersBGS
Tera Patron

Hi @NehruV ,

 

And what are your issue?

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/