- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi
Whenever the below "Dispatch" field is read only then the field named Part Information should be made mandatory.
And Dispatch field gets to be readonly when the form is saved.
So when the dispatch field is checked the part information should not be visible and only when the form gets saved and the dispatch field is read only the part information field is made visible and mandatory
How can we do that
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Abdul , try the onLoad script below, if this is on catalog form then use catalog client script
Script:
function onLoad() {
var dispatchField = 'dispatch';
var partInfoField = 'part_information';
var isDispatchChecked = g_form.getValue(dispatchField) == 'true';
var isDispatchReadOnly = g_form.isReadOnly(dispatchField);
if (isDispatchReadOnly && isDispatchChecked) {
g_form.setVisible(partInfoField, true);
g_form.setMandatory(partInfoField, true);
} else {
g_form.setVisible(partInfoField, false);
g_form.setMandatory(partInfoField, false);
}
}
If this solution helps you please don't forget to mark this solution as accepted and helpful, this will help others as well.
Regards,
Saurabh V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Abdul,
Try to use 'onload' Client script and create necessary condition to check if the field is readOnly. If the field is readOnly make the other field Mandatory
function onLoad() {
var depatchField= 'depatch_field';
var partInfoField= 'part_info_field';
var isReadOnly = !g_form.isEditableField(depatchField);
g_form.setMandatory(partField, isReadOnly);
}
Please like the feedback if the solution proposed is helpful for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
i wrote the below code it makes it mandatory whenever the form loads, this field should only be mandatory and visible if the condition such as dispatch check box is true and it is read only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
g_form.setReadOnly("field_name", !g_form.isNewRecord())
You can use the isNewRecord method from g_form to check if the form is open on a new record or existing. Not sure I follow the rest of the logic but display can be set with the setDisplay. True for show, false for hide
g_form.setDisplay("field_name", bool)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Abdul , try the onLoad script below, if this is on catalog form then use catalog client script
Script:
function onLoad() {
var dispatchField = 'dispatch';
var partInfoField = 'part_information';
var isDispatchChecked = g_form.getValue(dispatchField) == 'true';
var isDispatchReadOnly = g_form.isReadOnly(dispatchField);
if (isDispatchReadOnly && isDispatchChecked) {
g_form.setVisible(partInfoField, true);
g_form.setMandatory(partInfoField, true);
} else {
g_form.setVisible(partInfoField, false);
g_form.setMandatory(partInfoField, false);
}
}
If this solution helps you please don't forget to mark this solution as accepted and helpful, this will help others as well.
Regards,
Saurabh V.