Visibility of Initiate Deployment UI button to Development Team

Nivedha G
Tera Contributor

Hi,

    The Initiate Deployment button is currently visible to Release coordinator, but now there is a condition needed where it should be also visible to Development Team (We have to get development team group name from Feature record). I have given a script under Initiate Deployment UI action but the issue is now its showing for all the users and the script is not checking for Development Team.

 

function isUserInFeatureDevelopmentTeam() {

    var grFeature = new GlideRecord('rm_feature');

    grFeature.addQuery('parent', current.sys_id); 

    grFeature.query();

 

    while (grFeature.next()) {

        var devTeam = grFeature.u_development_team; 

        if (devTeam) {

            var grTeamMember = new GlideRecord('sys_user_grmember');

            grTeamMember.addQuery('group', devTeam);

            grTeamMember.addQuery('user', gs.getUserID());

            grTeamMember.query();

            if (grTeamMember.hasNext()) {

                return true; 

            }

        }

    }

    return false;

}

 

And in condition field of the UI action I have included the function name :

current.state == "25" &&

current.u_change_request.nil() &&

(current.assigned_to == gs.getUserID() || isUserInFeatureDevelopmentTeam());

 

What might be the issue here? Thanks in Advance

2 ACCEPTED SOLUTIONS

Hello @Nivedha G 

 

It doesn't works like that. You cannot write function in script section and call it in condition because condition is evaluated first and it doesn't has access to function you have written. So it will get null.

 

Please wrap this function in a script include and call that script include in your UI script condition part. 

 

&& ScriptIncludeName().METHODName() 

 

Method in which you wrote this script then it will work. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

Hello @Nivedha G 

 

current.state=="25"&&current.u_change_request.nil()&&current.assigned_to==gs.getUserID() && CheckDevelopmentTeamAccess().isUserInFeatureDevelopmentTeam(current.RELEASEFIELD)

 

Use above in the condition. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

10 REPLIES 10

Shivalika
Mega Sage

Hello @Nivedha G 

 

Where have you written this function ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

This function is written in the script section of Initiate Deployment UI action

Hello @Nivedha G 

 

It doesn't works like that. You cannot write function in script section and call it in condition because condition is evaluated first and it doesn't has access to function you have written. So it will get null.

 

Please wrap this function in a script include and call that script include in your UI script condition part. 

 

&& ScriptIncludeName().METHODName() 

 

Method in which you wrote this script then it will work. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Hi @Shivalika 

I have added the script include 

var CheckDevelopmentTeamAccess = Class.create();

CheckDevelopmentTeamAccess.prototype = {

    initialize: function () {},

 

    isUserInFeatureDevelopmentTeam: function (releaseSysId) {

        var userId = gs.getUserID();

        var grFeature = new GlideRecord('rm_feature');

        grFeature.addQuery('parent', releaseSysId); // Get features linked to the Release

        grFeature.query();

 

        while (grFeature.next()) {

            var devTeam = grFeature.getValue('u_development_team'); // Get development team (group)

            if (devTeam) {

                var grTeamMember = new GlideRecord('sys_user_grmember');

                grTeamMember.addQuery('group', devTeam);

                grTeamMember.addQuery('user', userId);

                grTeamMember.query();

                if (grTeamMember.hasNext()) {

                    return true; // User is in the development team

                }

            }

        }

        return false;

    },

 

    type: 'CheckDevelopmentTeamAccess'

 

and then have include the script include in condition field of UI action to the exisiting one:

current.state=="25"&&current.u_change_request.nil()&&current.assigned_to==gs.getUserID() && CheckDevelopmentTeamAccess().isUserInFeatureDevelopmentTeam()

 

But after inlcuding this also Initiate Deployment button is not visible to development team and before it was visible to release coordinator now its not visible for them as well now.Could you please help us in this.Thanks in advance