What is the sys_id gs.executeNow() is returning?

JDX7913
Tera Guru

I have a code on a record producer that fires "gs.executeNow()" to trigger a scheduled data import. When I put "gs.addInforMessages(gs.executeNow())" I am getting a sys_id back, however, what is that sys_id? Is it the sys_id of "concurrent imports sets" or "import sets" because I can't find where that sys_id is located at?

Here is the sample code of gs.executeNow().

function fireTransformMap(){
	var exportGr = new GlideRecord("scheduled_import_set");
	exportGr.addQuery("sys_id", "fc2bcbf2db9a451077953b98f4961920");
	exportGr.query();
	if (exportGr.next()) {
		gs.addInfoMessage(gs.executeNow(exportGr)); // this is for scoped app, trigger schedule import
	}
}
10 REPLIES 10

@Aman Kumar weird that doesn't seem right at all.

If that doc is to be believed then the returning sys_id should be the one I am passing in, "fc2bcbf2db9a451077953b98f4961920."

Instead I am getting a new sys_id each time I am running the script (ex, "f60a3a1edb3f8d9036890825ca9619bb").

You are getting the sys_id of the scheduled job trigger which can be found on the "sys_trigger" table, please search with the sys_id.

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

It's probably returning the instance of the scheduled job.

That is, the job listed in the following list.

https://<instance name>.service-now.com/sysauto_script_list.do

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

I've executed the following script in background script.

  var jobId = 'b48d371e97f3011086d3b4b3f153aff6';
  var now_GR = new GlideRecord('sysauto_script');
  if (!now_GR.get(jobId)) {
    throw new Error('Unable to find import job');
  }
  gs.info(gs.executeNow(now_GR));

The result was as follows:

When I click on "available here", it shows me the value of gs.executeNow() is a jobId.

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

I've executed the following script from background script.

  var jobId = 'b48d371e97f3011086d3b4b3f153aff6';
  var now_GR = new GlideRecord('sysauto_script');
  if (!now_GR.get(jobId)) {
    throw new Error('Unable to find import job');
  }
  gs.info(gs.executeNow(now_GR));

The result is as follows.

find_real_file.png

Clicking on "1" under "Row Count" shows the following page.

find_real_file.png