This may seem a simple task to you experts out there, but I am having problems finding out how to place the contents of an array into a global field.
Firstly, I am getting all the current UserGroups by doing the following:
var Groups = security.getGroups();
var showArray = new Array(Groups.getMaxRowIndex());
for ( var i = 0 ; i < Groups.getMaxRowIndex() ; i++ )
showArray[i] = Groups.getValue(i + 1, 2);
How do I then place the Array contents into a global field?
I should add, that what I want to do is to display the UserGroupID and UserGroup Name, i.e.
1 GroupNameA
2 GroupNameB
etc. etc.
Thanks for your help
You can directly “paste” the values into a global
var Groups = security.getGroups();
globals.myGlobal = "";
for ( var i = 1 ; i <= Groups.getMaxRowIndex() ; i++ )
{
globals.myGlobal += Groups.getValue(i, 1) +" "+Groups.getValue(i, 2)+"\n";
// ID + GroupName + "backslash new line"
}
That’s brilliant. Thanks very much.
One other small point, is it possible to sort the Array into GroupName alpha sequence.
This code sorts on group name.
It first captures the dataset values in a separate array,
which is then sorted before sent to the global.
Bit of a workaround.
I’ll ask dev team if they can add a sort method to the Dataset object
myDataset.sort(columnName/Nr);
var Groups = security.getGroups();
var groupsArray = new Array()
globals.myGlobal = "GROUPNAME\tID\n"; \\backslash t stands for TAB
for ( var i = 1 ; i <= Groups.getMaxRowIndex() ; i++ )
{
//capture values in array
groupsArray[i-1] = Groups.getValue(i, 2) +"\t"+Groups.getValue(i, 1);
}
groupsArray.sort(); //sort the array
//loop through the array and fill the global
for ( var i = 0 ; i < groupsArray.length ; i++ )
{
globals.myGlobal += groupsArray[i]+"\n";
}