-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnections.gs
More file actions
38 lines (34 loc) · 1.4 KB
/
Connections.gs
File metadata and controls
38 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* CloudSimple 3.0
by Naveen Rokkam, Paul J. Modderman, Gavin P. Quinn - Mindset Consulting
v3.0 20181205 - Open Source Software
*/
function getActiveConnection(){
var allConnections = JSON.parse(PropertiesService.getUserProperties().getProperty('CONNECTIONS'));
for(var i = 0; i < allConnections.connections.length; i++){
if(allConnections.connections[i].active){
PropertiesService.getUserProperties().setProperty('AUTH', allConnections.connections[i].base64Auth);
return allConnections.connections[i];
}
}
//if we get here, there was no connection returned
throw "No default connection set up";
}
function getConnections(){
var allConnectionsString = PropertiesService.getUserProperties().getProperty('CONNECTIONS');
if(allConnectionsString != null){
var allConnections = JSON.parse(allConnectionsString);
return allConnections;
}
}
function saveConnections(connections){
var allConnections = {connections:[]};
for(var i = 0; i < connections.length; i++){
if(connections[i].active == true){
connections[i].base64Auth = Utilities.base64Encode(connections[i].sapUserName + ':' + connections[i].sapPassword);
PropertiesService.getUserProperties().setProperty('AUTH', connections[i].base64Auth);
}
allConnections.connections[i] = connections[i];
}
PropertiesService.getUserProperties().setProperty('CONNECTIONS', JSON.stringify(allConnections));
}