autopopulate

Bhavani1995
Tera Contributor

when selecting rc category as messaging , rc sub category as storage then rc details should set to none available and rc category as network , rc sub category as software then rc detail field should set to none available without script

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Any screeshot to understand this better.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Bhavani1995 

please share what script did you try and what didn't work

try this -> ensure you give correct value during comparison and while setting the value in rc_detail

You will require 1 onchange on RC category and 1 onchange on RC sub category

Script will be same in both

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

    // Get the values of rc_category and rc_sub_category
    var rcCategory = g_form.getValue('rc_category');
    var rcSubCategory = g_form.getValue('rc_sub_category');

    // Check the conditions and set rc_detail accordingly
    if ((rcCategory == 'messaging' && rcSubCategory == 'storage') ||
        (rcCategory == 'network' && rcSubCategory == 'software')) {
        g_form.setValue('rc_detail', 'None Available');
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Rishi_11
Kilo Sage

Hi @Bhavani1995 

If I understand correctly, you want to set "rc detail" field to "non available" in two cases.

  1. rc category =  messaging and rc subcategory = storage OR
  2. rc category = network and rc subcategory = software.

I would recommend a client script for this scenario but to answer your question without using a script, you can try the following:

  • If these fields are variables on a catalog item, then this can be pretty easily done using catalog UI policy and catalog UI policy action, just define your conditions in the UI policy and you can use "Value Action" as "Set Value" in UI policy action and set the appropriate value.
  • But if this is some table then catalog UI policy won't work here and since you do not want to write a script you can use a Before Insert BR, define the conditions in when to run tab and use the "Set Field Value" in the action tab and set the appropriate value in the field. In this case, it will be handled server side and you won't be able to see live changes on client.

 

Please mark this response as correct or helpful if it assisted you with your question.

 

Thanks,

Rishi.