Is there a way to copy a role, I want to create co...
# suitescript
t
Is there a way to copy a role, I want to create copy of administrator role, with all permissions ? Is the roles scriptable, I have tried adding values to transaction machine this with console, not able to do so
b
cant copy the administrator role, its special
the sublist is scriptable, though the code you are using wouldnt work in general
t
it also doesn't work
b
what code did you use
t
nlapiSelectNewLineItem('tranmach')
nlapiSetCurrentLineItemText('tranmach','permkey1','TRAN_AUDIT');
nlapiSetCurrentLineItemValue('tranmach','permlevel1',4);
nlapiCommitLineItem('tranmach')
w
re: Administrator Role. At least since 2020.2 you can compare the Administrator role with your custom role and make sure that you have ALL(almost) permissions. You can also add Core Administration Permissions to the role to gain some extra permissions. But it will never be exactly as the Administrator role.
t
is it only because its custom ?
w
Yes, and look at the page in the link, it describes some of the differences.
t
oho
b
if you use nlapiSetCurrentLineItemText, then expect to use the synchronous parameter
and the correct text permission
TRAN_AUDIT is an id, not a name
t
oh my bad , I actually tried with value, later changed it trying bruteforce : D This works with synchronous parameter Still, level is not working
b
code?
t
nlapiSelectNewLineItem('listsmach')
nlapiSetCurrentLineItemValue('listsmach','permkey3','REGT_BANK',false,true);
nlapiSetCurrentLineItemValue('listsmach','permlevel3',4,false,true);
nlapiCommitLineItem('listsmach')
b
`firefieldchanged`to true, best to leave the defaults unless you want to change its behavior
t
thanks a lot @battk and @Watz
Here is how I did this, &xml=t of administrator role, Got the xml of particular machine/sublist Converted it to json online And rest code is here which I ran on console
w
Nice trick to get the xml=T of the Administrator role. I think another way might have been to export the sdf-xml with: https://system.app.netsuite.com/app/suiteapp/devframework/xml/xmlexport.nl?recordtype=role&id=3 rename it and then import it into the account again. Haven't tested it though.