What I did to solve this in the past is one of two ways,
-
Creating a new table inside the database with "Name" (String) | "ID" (String) and adding the group's name & id when ver it's created. Calling them into a List, Object, etc at the OnApplicationStart (readfile "firstrun.txt" with value of "true/false" if true create all groups that are needed else read database to variable) No point in reading the Database each time for the ID unless you plan on changing it.
-
Creating a config file that's read using the project_path() function.
To change a [[GLOBAL:JSON_OBJECT]] value you need to call the JSON outside of BAS variable change the value, then back to BAS & save the [[GLOBAL:JSON_OBJECT]] to file. Like so..
var obj = [[GLOBAL:JSON_GROUPINFO]];
obj[([[GROUP_NAME]])] = {"ID": [[GROUP_ID]]};
PSet("basglobal", "JSON_GROUPINFO", JSON.stringify(obj));
You can change the value easy on local variables
[[JSON_OBJECT]][([[GROUPNAME]])] = {"ID": [[GROUP_ID]]} // Creating the ID Object
// 3 below is to CHANGE (not create)
[[JSON_OBJECT]][([[GROUPNAME]])].ID = [[NEW_ID]] // (For variables as the name since [[VAR1]][[[VAR2]]] gives a JSON error (x3 [[[ & ]]] )
[[JSON_OBJECT]].MyGroupName.ID = [[NEW_ID]]
[[JSON_OBJECT]]["MyGroupName"]["ID"] = [[NEW_ID]]
To get the project_path it will return the .xml file too. Here's a snippet to take that out.
Value AS Expression
(project_path()).match(/(.*)[/]/)[1]||''
Can add more Regex to allow the path be outside the AppData just encase you update the bot with a new BAS Studio Version.
Let me know if this helps!
Allister ☯