List Control script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 05:07 AM
Hi All,
I am working on a requirement where on SC Task related list New/Edit button should be visible to the user who is member of SC Task assignment group.
How to write script in list control, Please help me with this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 05:25 AM
Hello @priyanka1028 ,
var userObj = gs.getUser();
if (userObj.isMemberOf('6eb7eb54dbef5c548d5905d2ca9619b6')) //Group sys id
{
answer = true;
}
else
{
answer = false;
}
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 05:54 AM
Hi there @priyanka1028
you can use a script in the list control.
- Navigate to the list control script for the SC Task related list.
- Use Script to dynamically control the visibility of the buttons based on the user’s membership.
function onLoad() {
// Get current user's groups
var currentUserGroups = g_user.getMyGroups();
// Check if the SC Task assignment group is in the user's groups
var scTaskAssignmentGroup = 'YourAssignmentGroupID'; // Replace with your actual assignment group ID
var userIsMember = currentUserGroups.indexOf(scTaskAssignmentGroup) !== -1;
// Show New/Edit buttons based on user's membership
if (userIsMember) {
g_list.allowAdd = true; // Show New button
g_list.allowEdit = true; // Show Edit button
} else {
g_list.allowAdd = false; // Hide New button
g_list.allowEdit = false; // Hide Edit button
}
}
If this helps kindly upvote and accept the response thanks much.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 07:46 AM
How to access SC task assignment group by scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 08:40 AM
I have tried with below script but it is not working.
if(parent.active == true){
var assign_group = parent.getValue('assignment_group');
var grp = gs.getUser().isMemberOf(assign_group);
if((gs.hasRole("admin")) || grp){
answer = false;
}else {
answer = true;
}
} else
answer = true;