- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 02:40 AM
Hi everyone, Im trying to set a value of a field "Confidentiality" depending on 3 radio buttons on a record producer, the buttons are:
"Public" -> Choices: "yes"
"Confidential" -> Choices: "yes"
"Restricted" -> Choices: "yes"
When I click one of the buttons it clears the value of the others, what Im trying to do is if the person chooses for exemple "Public", the field "Confidentiality" will be "Public" I've tried with this code:
function onSubmit() {
//Type appropriate comment here, and begin script below
if(public_option_1 == 'yes'){
u_confidentiality = 'Public';
}
else if(confidential_option1 == 'yes'){
u_confidentiality = 'Confidential';
}
else{
u_confidentiality = 'Restricted';
}
}
But it didnt work does any one know how to do this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 02:57 AM
Try below -
function onSubmit() {
var publicOption = g_form.getValue('public_option');
var confidentialOption = g_form.getValue('confidential_option');
var restrictedOption = g_form.getValue('restricted_option');
var confidentialityField = 'u_confidentiality'; // Replace with the actual field name
if (publicOption == 'yes') {
g_form.setValue(confidentialityField, 'Public');
} else if (confidentialOption == 'yes') {
g_form.setValue(confidentialityField, 'Confidential');
} else if (restrictedOption == 'yes') {
g_form.setValue(confidentialityField, 'Restricted');
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 02:57 AM
Can you share the complete code along with screenshots?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 02:57 AM
Try below -
function onSubmit() {
var publicOption = g_form.getValue('public_option');
var confidentialOption = g_form.getValue('confidential_option');
var restrictedOption = g_form.getValue('restricted_option');
var confidentialityField = 'u_confidentiality'; // Replace with the actual field name
if (publicOption == 'yes') {
g_form.setValue(confidentialityField, 'Public');
} else if (confidentialOption == 'yes') {
g_form.setValue(confidentialityField, 'Confidential');
} else if (restrictedOption == 'yes') {
g_form.setValue(confidentialityField, 'Restricted');
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar