スクリプトをシステムとして実行する方法Summaryトラブルシューティング中に、システムユーザーとしてコードを実行する場合があります。スケジュールワーカースレッドはシステムユーザーです。 システムが実行する「スクリプト」変数のスクリプトを使用して、以下のコードを構成します特殊文字をエスケープすることを忘れないでくださいaddSecond メソッドでは、スクリプトを実行するタイミングを定義できます。すぐに実行するには 1 秒に設定します次に、以下のコードを /sys.scripts.do で実行します。これにより、スケジューラーワーカーが取得する [sys_trigger] レコードが作成されます。「script」変数で定義されたスクリプトで「current」にする変数を使用して、変数 gr を定義します。Instructions//get the gr of whatever record you want current to be on the script var gr = new GlideRecord("sc_req_item"); gr.get("aeed229047801200e0ef563dbb9a71c2"); //execute one second after running this script var gdt = new GlideDateTime(); gdt. addSeconds(1) gs.info(gdt); //define the script you want to run, in this example it's the stack trace, and don't forget to escape special charectors var script = "gs.log('***** DEBUG - op:'+ current.operation() + ', sess:' + gs.getSessionID() + ', time:' + new Date().getTime() + ', sys_id:' + current.sys_id + ' - \\n' + GlideLog.getStackTrace(new Packages.java.lang.Throwable()), 'Stacktrace Debug');"; //create the sys_trigger record to be executed by the schedule worker thread var sched = new ScheduleOnce(); sched.script = script; sched.setTime(gdt); sched.setDocument(gr); sched.setLabel("run this as system"); sched.schedule();