Service Manager / Service Center User Discussions
cancel

Copy a SecRole

SOLVED
Go to solution
Honored Contributor.. Ivis Honored Contributor..
Honored Contributor..

Copy a SecRole

Hi - I want to copy a sec role to make minor modifications to it, but when I go in admin mode - change the name of the secRole from 'incident manager' to 'xx incident manager' it revertes to the default sec area set up. I understand this - it does the same operation as a new - but it is a frustrating job to go and change every area like this. It takes a lot of time.... 

Anybody done this? I cannot unload them either because the same thing happens... 
Why cant they have a clone command here? It is 2017..... 

Ivis

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Carlos_V_SM Acclaimed Contributor.
Acclaimed Contributor.
Solution

Re: Copy a SecRole

Hello Ivis,

hope you are doing fine.

I found a kind of workaround you can try, I couldn;t tested since I don't have my SM 9.50 test environment yet, please see below:

Question: (please take in mind that this is not 9.50, may be 9.4x)

I am using the option to add a new secRole by using a oob secRole, add a suffix, and press Add.

My aim was to copy the role, and make a minor change to the secRights regarding folder access.

The result is that new secAreas and secRights are created for this secRole with default values.

It is pretty time consuming to cange all the rights to the rights I need. so my question is:

Did anyone build something to copy a secRole including the secAreas and secRights?

It saves a lot of time.

Answer:

Below SL will help you:

 

function cpyRole(copyRoleName, newRoleName,newRoleDes)

{

    var role = new SCFile("secRole");

    var rc = role.doSelect("name=\"" + copyRoleName + "\"");

    if(rc == RC_SUCCESS)

    {

        role.name = newRoleName;

        role.description = newRoleDes;

       

        // copy rights

        var rights = new SCFile("secRights");

        rc = rights.doSelect("role=\"" + copyRoleName + "\"");

        while(rc == RC_SUCCESS)

        {   

            rights.role=newRoleName;

            rights.doInsert();

            rc=rights.getNext();

        }

        // copy role

        role.doInsert();

    }

}

cpyRole("change analyst change", "newchange analyst change", "new");

 

Carlos Villalobos R
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
4 REPLIES
Carlos_V_SM Acclaimed Contributor.
Acclaimed Contributor.

Re: Copy a SecRole

Hello Ivis

hope you are doing fine.

Could you please let me know your current version?

what the sm.log file says after the changes? warning, validation, error message?

web or client?

Carlos Villalobos R
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
Honored Contributor.. Ivis Honored Contributor..
Honored Contributor..

Re: Copy a SecRole

HI - 

Version 9.50 OOB, web and win client

No warning - not anything. 

It should be an option to 'clone' the secRole. As now only 'Add' option is available in admin mode. 

So here is what you do to reproduce: 

database manager (db) -> check admin mode -> table: secRole -> find incident mananger role -> type TMP inicident manager -> press Add. 

Result: the new TMP incident manager will get the default settings and not the settings of incident manager ... 

BR Ivis. 

Highlighted
Carlos_V_SM Acclaimed Contributor.
Acclaimed Contributor.
Solution

Re: Copy a SecRole

Hello Ivis,

hope you are doing fine.

I found a kind of workaround you can try, I couldn;t tested since I don't have my SM 9.50 test environment yet, please see below:

Question: (please take in mind that this is not 9.50, may be 9.4x)

I am using the option to add a new secRole by using a oob secRole, add a suffix, and press Add.

My aim was to copy the role, and make a minor change to the secRights regarding folder access.

The result is that new secAreas and secRights are created for this secRole with default values.

It is pretty time consuming to cange all the rights to the rights I need. so my question is:

Did anyone build something to copy a secRole including the secAreas and secRights?

It saves a lot of time.

Answer:

Below SL will help you:

 

function cpyRole(copyRoleName, newRoleName,newRoleDes)

{

    var role = new SCFile("secRole");

    var rc = role.doSelect("name=\"" + copyRoleName + "\"");

    if(rc == RC_SUCCESS)

    {

        role.name = newRoleName;

        role.description = newRoleDes;

       

        // copy rights

        var rights = new SCFile("secRights");

        rc = rights.doSelect("role=\"" + copyRoleName + "\"");

        while(rc == RC_SUCCESS)

        {   

            rights.role=newRoleName;

            rights.doInsert();

            rc=rights.getNext();

        }

        // copy role

        role.doInsert();

    }

}

cpyRole("change analyst change", "newchange analyst change", "new");

 

Carlos Villalobos R
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
Honored Contributor.. Ivis Honored Contributor..
Honored Contributor..

Re: Copy a SecRole

Hi - 

Worth a Kudos I agree :) It works well. 

But I would also like a possibility to unload and load secRole - now I have to remake them in every system (dev, prod and test)... 

Perhaps HPE needs to make this... 

BR Iivis.