- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 01:23 AM
So, i have one record producer, and there is one variable on it 'Department'
i want this variable to auto populate value of department from user table and it should be read only and hence i was thinking to use Default value to get this done.
but, if user don't have department then this variable should be editable
so anyone can help me how i can do this, do i need to script include for making it editable as default value can't do that i guess
Thanks!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 02:07 AM
@akshayp ,
Below is the modified code
var deptField = 'department'; // replace with the name of the 'Department' field on your form
var userDept = g_user.department;
if (userDept) {
// If the user has a department value, set the value and make the field read-only
g_form.setValue(deptField, userDept);
g_form.setReadOnly(deptField, true);
} else {
// If the user doesn't have a department value, make the field editable
g_form.setReadOnly(deptField, false);
}
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 02:07 AM
@akshayp ,
Below is the modified code
var deptField = 'department'; // replace with the name of the 'Department' field on your form
var userDept = g_user.department;
if (userDept) {
// If the user has a department value, set the value and make the field read-only
g_form.setValue(deptField, userDept);
g_form.setReadOnly(deptField, true);
} else {
// If the user doesn't have a department value, make the field editable
g_form.setReadOnly(deptField, false);
}
Shravan
Please mark this as helpful and correct answer, if this helps you