I have some google sheets that should have some functions where the ordinary user should be able to run them but I don't want them to able to see the code, so what I am doing now is:
I believe your goal is as follows.
From your following title
I need to make the end user able to run some functions without google apps script without giving him access to the code
In this case, for example, as a workaround, how about using Web Apps? I thought that when Web Apps is used, your goal might be achieved. The flow of this workaround is as follows.
Sample script of Web Apps is a Google Apps Script. So please create a project of Google Apps Script.
If you want to directly create it, please access https://script.new/. In this case, if you are not logged in to Google, the log-in screen is opened. So please log in to Google. By this, the script editor of Google Apps Script is opened.
Please copy and paste the following script to the created Google Apps Script project and save it. This script is used for Web Apps.
function doGet(e) {
const {value} = e.parameter;
// do something: Please put the script you want to run.
return ContentService.createTextOutput(`<result>Updated ${value}</result>`).setMimeType(ContentService.MimeType.XML); // Here, you can return the value.
}
This script is a sample script. Even when you directly use this, you can test this workaround.
The detailed information can be seen at the official document.
https://script.google.com/macros/s/###/exec
.
In order to test this Web Apps, please put your Web Apps URL, the inputted value, and the formula as follows.
In this test, the sample formula is =IMPORTXML(CONCATENATE(A1,"?value=",A2),"/result")
.
By this flow, the user can run your script without both authorizing the scopes and showing your script. In this workaround, the value is returned as XML data. By this, Web Apps can be used with IMPORTXML
.