Onload Clientscript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 11:33 PM
Hi Community,
How to write the onload client script this should execute only for 'spares' view in alm_stockroom and alm_hardware table .In the onload, I have to check members part of sparing user. if yes , make all fields to read only else it should editable ?
Thanks,
Manu
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 01:41 AM
HI @Manu143 ,
I trust you are doing great.
Please find the sample code for the same.
function onLoad() {
// Check if the current view is 'spares'
var viewName = g_form.getViewName();
if (viewName !== 'spares') {
return; // Exit if not 'spares' view
}
// Check if the current table is alm_stockroom or alm_hardware
var tableName = g_form.getTableName();
if (tableName !== 'alm_stockroom' && tableName !== 'alm_hardware') {
return; // Exit if not the specified tables
}
// Check if the current user is a member of the sparing user group
var currentUser = gs.getUser();
var isSparingUser = currentUser.isMemberOf('your_sparing_user_group_sys_id');
// Make fields read-only if the user is a sparing user, otherwise keep them editable
if (isSparingUser) {
g_form.setReadOnly(true);
} else {
g_form.setReadOnly(false);
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi