Reputation: 3
I have a shared workbook that can be updated by different people. My excelscript online gets the last user who updated the workbook with this code:
// Get the document properties.
const properties: ExcelScript.DocumentProperties = workbook.getProperties();
// Get Author
let Author = properties.getLastAuthor();
My script also updates the workbook data but, after the updates, is not able to retrieve the name of active user who is running the script (and updating automatically the data)
I have tried some code to give time to the script retriving the correct name but it always gets the previous name not the actual one. The code I used:
const application = workbook.getApplication();
application.calculate(ExcelScript.CalculationType.fullRebuild);
let subject1 = "Entrevista anual 2023 firmada en " + currentDateTime;
console.log(subject1);
Any idea about retriving the name of the user who is running the script?
Upvotes: 0
Views: 718
Reputation: 211
A possible workaround is to add and then delete a comment, e.g:
let c = selectedSheet.addComment("K1", "working");
console.log(c.getAuthorName());
c.delete();
Only email and name are available though, not the userid.
Upvotes: 1