Background Script Execution output to sn-scriptsync #480
Replies: 5 comments 4 replies
-
I implemented a POC in the following two forks: https://github.com/abhishekg999/sn-scriptsync The style and everything can obviously be customized to how the community believes is best. setTimeout(() => {
document.querySelector('input[name=runscript]').click()
snuStartGlobalBackgroundScript(editor.getModel().getValue(), e.detail.content.instance, function (response) {
console.log("BG script executed");
console.log(response);
snuScriptSyncPostData({action: "writeResponseToTab", instance: e.detail.content.instance, response: response});
});
// document.querySelector('input[name=runscript]').click()
}, 500); It then sends this back via the SyncPostData. In the VSCode extension, we simply catch this action, and write it in the Output channel. const outputChannel = vscode.window.createOutputChannel('Background Execution');
outputChannel.clear();
outputChannel.appendLine(jsn.response);
outputChannel.show(); |
Beta Was this translation helpful? Give feedback.
-
Updated to use VSCode Webview Panel. This keeps the code much cleaner as well and removes the he dependency. |
Beta Was this translation helpful? Give feedback.
-
Thanks for checking in on SN Devs Slack
SN Utils |
Beta Was this translation helpful? Give feedback.
-
script-2013.bg.js.-.sn-scriptsync.-.Visual.Studio.Code.2024-03-07.17-46-13.mp4Removed most changes in ServiceNow-Utils directory, made the |
Beta Was this translation helpful? Give feedback.
-
Good, maybe just make the naming of the functions and variables consistent like below and I'm ok with a scriptsync PR, thanks!
|
Beta Was this translation helpful? Give feedback.
-
Hi, this would require changes in both SN-Utils as well as the VSCode extension, but the idea would be bg script output back to VSCode when using the "Execute Background script" action. Personally, its quite convenient to work in VSCode when testing / working in BGscripts, and it would be pretty nice to be able to work entirely in the editor during this process.
The existing framework in
scriptsync.js
andextension.ts
seems to have the necessary foundations to implement this. The output can be written to a vscode Output Channel usingvscode.window.createOutputChannel
, and the content can simply be the information in#result > pre
.Beta Was this translation helpful? Give feedback.
All reactions