I personally haven't tried anything regarding this, but the first thing comes to mind is an IF ELSE statement using a source-path that would be included in the script. Then when you "deploy" to a stream the files would change locations/paths. Therefore the script would automatically account for it.
A few functions that come to mind to get a path...
Please let me know if you end up finding a viable solution. If I end up finding time to test this I will reply back.
If the Source is file system, then we can apply IF ELSE and use the functions which you mentioned.
what if we are using OLEDB conection to connect to SQL server?
the ideal solution for this would be, We need some qlik function to identify the stream Name, that way we can apply IF ELSE and swap the connections.
First of all you need to create 4 data connection. DEV, UAT, PROD and POSTGRE_QSR(qlik sense database). We need QSR connection to fetch the stream name of the app.
let appId = DocumentName();
LIB CONNECT TO 'POSTGRE_QSR';
ID as AppID,
Name as StreamName;
FROM public."Apps" app
left join public."Streams" str on app."Stream_ID"=str."ID"
let DataSourceName = peek('StreamName');
DROP TABLE Temp_App_Stream;
LIB CONNECT TO '$(DataSourceName)';
If you get the logic, you are able to modify this script based on your needs.
Hope it helps.