DickDi Posted August 3, 2019 Share Posted August 3, 2019 Hello,everybody! I write a javascript in alfred workflow, try to return the json and copy the result to clipboard at the same time. Could anybody tell me how to make it?Thanks~ function run(argv) { var temp = argv[0]; var num; num = temp * 1000; return JSON.stringify({items: [ {title: "The number is :", subtitle:num } ]}) //return num;//It dosn't work. } Link to comment
deanishe Posted August 3, 2019 Share Posted August 3, 2019 2 hours ago, DickDi said: return JSON.stringify({items: [ {title: "The number is :", subtitle:num } ]}) //return num;//It dosn't work. You can't use multiple returns like that: once a return statement is executed, the function has finished. Have a look at the Script Filter documentation and the example workflows built into Alfred. If you want to pass num back to Alfred, you have to put it in the item's arg property. return JSON.stringify({items: [ {title: "The number is :", subtitle: num, arg: num // <-- here } ]}) Link to comment
DickDi Posted August 3, 2019 Author Share Posted August 3, 2019 2 hours ago, deanishe said: You can't use multiple returns like that: once a return statement is executed, the function has finished. Have a look at the Script Filter documentation and the example workflows built into Alfred. If you want to pass num back to Alfred, you have to put it in the item's arg property. return JSON.stringify({items: [ {title: "The number is :", subtitle: num, arg: num // <-- here } ]}) Thanks so much! I reckon that I should study hard about workflow.😁😁 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now