Help with code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:00 AM
Hi @B_pppppp ,
Could you try below code
function onLoad() {
// Get a reference to the business_service control
var fieldObj = g_form.getControl('business_service');
// Check if control exists and there's more than one option
if (fieldObj && fieldObj.options.length != 1) {
// Set business_service field to mandatory
g_form.setMandatory('business_service', true);
}
}
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:05 AM
@Astik Thombare Thank you but it doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:10 AM
@B_pppppp Please try with below
function onLoad() {
// Get a reference to the business_service field
var fieldObj = g_form.getControl('business_service');
// Check if control exists and if the field is empty
if (fieldObj && g_form.getValue('business_service') == '') {
// Set business_service field to mandatory
g_form.setMandatory('business_service', true);
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:12 AM
@Maddysunil , thank you! It works a little too well now: it makes the field mandatory even if I can't choose any value for it because there's none