Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

List Control script

priyanka1028
Tera Contributor

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.

4 REPLIES 4

Not applicable

Hello @priyanka1028 ,

 

 

var userObj = gs.getUser();
if (userObj.isMemberOf('6eb7eb54dbef5c548d5905d2ca9619b6'))  //Group sys id
{
answer = true;
}
else
{
answer = false;
}

 

 

Thank you.

Its_Azar
Mega Sage

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. 

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

How to access SC task assignment group by scripting.

priyanka1028
Tera Contributor

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;