How to update Multiple choice field based on Singletext field having ClientScript Integer Validation

VIKASM535239375
Kilo Sage

How to update Multiple choice field based on Single text field having Client Script Integer Validation in Catalog Item?

If Single Text Integer field is less than 500 option1 to be selected.

If Single Text Integer field is greater than 500 option2 to be selected.
1 ACCEPTED SOLUTION

@VIKASM535239375 

you can use onChange catalog client script for this

Something like this but please enhance further

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

    var integerValue = parseInt(newValue, 10);
    var multipleChoiceField = 'your_multiple_choice_field'; // Replace with your actual multiple-choice field name

    if (integerValue < 500) {
        g_form.setValue(multipleChoiceField, 'option1'); // Replace 'option1' with the actual value for the first option
    } else if (integerValue >= 500) {
        g_form.setValue(multipleChoiceField, 'option2'); // Replace 'option2' with the actual value for the second option
    }
}

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@VIKASM535239375 

Sorry your requirement is not clear.

please share some screenshots.

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

How to update Multiple choice field based on Single text field having Client Script Integer Validation in Catalog Item?

If Single Text Integer field is less than 500 option1 to be selected.

If Single Text Integer field is greater than 500 option2 to be selected.

@VIKASM535239375 

you can use onChange catalog client script for this

Something like this but please enhance further

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

    var integerValue = parseInt(newValue, 10);
    var multipleChoiceField = 'your_multiple_choice_field'; // Replace with your actual multiple-choice field name

    if (integerValue < 500) {
        g_form.setValue(multipleChoiceField, 'option1'); // Replace 'option1' with the actual value for the first option
    } else if (integerValue >= 500) {
        g_form.setValue(multipleChoiceField, 'option2'); // Replace 'option2' with the actual value for the second option
    }
}

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

Hi Ankur,

 

How to update Multiple choice field based on Single text field having Client Script Floating Validation in Catalog Item?

If Single Text Floating field is less than 500 option1 to be selected.

If Single Text Floating field is greater than 500 option2 to be selected.