HOW: Run file actions while phone is locked

I have a piece of my shortcut ( retrieving informatie from a .txt file) that - after some testing and research - doesn’t do what It should to do while my phone is locked.

When my phone is unlocked, however, it works perfectly.

Do you know if it’s at all possible to do this? If yes, how?

I dont get asked about running actions while my phone is locked. That option is already turned on in settings

Is your shortcut doing anything else? Your screenshot would suggest it is.

Have you tried paring the shortcut down to confirm it really is the actions you are sharing in that screenshot that are the issue? I would be a little surprised if it was. It tends to be interactions with apps, not files, that create locked device issues.

I added “append to note” after every step in the entire shortcut. I noticed that the text in the searched file wasn’t extracted. So something there is not working, when locked

Okay try this shortcut that both writes and reads a text file. It works for me without unlocking my phone if I set it to run, as an example, as a timed automation.

https://www.icloud.com/shortcuts/d8c2b11d0ff042c485cab3c936989713

Does it work for you?

If so, does that then help you narrow things down based on what I wrote earlier?

Tested it again by creating shortcuts from scratch: when iphone is unlocked it can extract text from files, when it’s locked it can’t.

Is there another way to store and extract data via shortcuts? Somehow notes doesn’t work anymore for this

If that was true, the shortcut I shared above would not work for me. But it seems to in my testing.

Can you confirm I am wrong and that my shortcut does not work?

Yes yours works, and by accident i found the real problem. It’s not in the file part as I thought before, it’s in the text part, which comes before the file part.

Could you try running this when locked and see if your notification shows the values: Shortcuts

First copy 3 random words on seperate lines to your clipboard. I tried
This is
a
test

It shows values when unlocked, but not when locked

I get a notification with the values in for me using your shortcut and lines of text (4 words on 3 lines rather than 3 words).

Double check your shortcut settings. They should have got set on first run.

I am clueless why it’s not working for me… the setup couldn’t be simpler and yet it’s not working while my phone is locked and the privacy settings are as they are supposed to be

I suspect you have a permission issue on that particular shortcut if my earlier one ran okay for you.

What happens with this one?

https://www.icloud.com/shortcuts/b8e399e188fb40848ce1a28cd76c6262

No notification at all, while my settings are ok I think

No. They are not correct.

I wasn’t asked to grant access to any other action. Can I force that?

Try removing the Lock Screen action temporarily. See if it prompts you. If it does, accept, then add it back.

Thanks for the tip but my very long shortcut that doesn’t run when locked has no lock action in it. So I don’t know how to proceed and get that one to work while locked

So that was a suggestion for you for trying with the shortcut I shared earlier, not a suggestion for your own longer shortcut.

Trying to debug issues in a shortcut we get peeks into isn’t practical.

You have previously tracked down the issue, only to discover through looking at shortcuts that I have created and shared in full, that what you were sure was the issue was not in fact the issue. You did not have the same success with the last shortcut I shared and we could see that you were missing a permission. My suggestion was for something to try (no guarantee - remember I don’t have this issue) that might unlock the provision of the missing permission.

My hope would be that as you build up your understanding through these smaller example shortcuts that you would be able to try building smaller, similar ones yourself and have greater success until you eventually reach a point where you know enough to fix or create in another way your original shortcut - the one that we can’t see and can’t reproduce the issue for.

I don’t know if that makes sense to you, but in developing solutions, it is not uncommon when you encounter a difficult issue to pull things apart to break it down and simplify it. Change the complex issue into several simpler issues that you have a better chance of solving. Then, armed with that knowledge and experience you can either attempt to address the original issue in place, or build up the solution from your smaller parts and knowledge.

Thanks. I pulled my shortcut apart several times. Each time something else goes wrong. This time I found out that when I set up an automation that extracts two variables from an email (subject and content) and seperate them by comma, only the subject line is extracted while content is not (tried this with other splitting options as well). This is only the case, however, when my phone is locked. When it’s unlocked, both variables get extracted.

I found this out by appending the shortcut input (subject,content) to a note. Once when locked, once when unlocked.