The CreatorCon Call for Content is officially open! Get started here.

Scheduled import: How to specify the datasource dynamically?

Stephen W_
Giga Guru

According to Scheduling Data Imports - ServiceNow Wiki

I should be able to override the datasource in a scheduled data import using the "Pre script".

However, it does not use either:

data_source = "My DS Name";

or

var grDS = new GlideRecord("sys_data_source");

if (grDS.get("name","My DS Name")){

  data_source = grDS;

}

if I leave the basic datasource field blank:

Unresolved data source for ScheduledImportJob


If I populate it, it hits the wrong datasource.

Is this a bug, bad documentation.. or am I just missing something?

Thanks,

-Stephen

Fuji patch12 hotfix1

14 REPLIES 14

Worth a shot but didn't work.   It executes whatever is defined in the datasource field no matter what.


I've tried:


data_source = <data source name>;


data_source = <data source sys_id>;


data_source = <datasource GR object>;



If I leave the data source field blank, and only define it in the pre-scritp, it doesn't execute the pre-script at all.



Though, I wish I could make sense of Harel's answer.. he implies he's currently doing this.




I think this has got to be a bug.


It's starting to feel like a bug. Perhaps time to reach out to customer support? I'll be interested to hear what they have to say.


HI Service Portal - ServiceNow


Contact Support | ServiceNow


I opened an incident on this, worked with ServiceNow for a while on this, helping test this and that.   Eventually they agreed it was a bug and opened PRB1070186.   Then six days later closed the PRB without explanation.   I've already worked around this so it's not the end of the world.. would like to know why it was closed though.


Thank you for the update Stephen. I would call and follow up to find out why the PRB was closed. It seems a bit odd that it would be closed without any reason. I didn't see any fix targets on the PRB, so I don't know why they would have closed it.


Initially when I reached out to ask why it was closed, it was suggested that we were using the pre-script wrong.   That we should be using that to alter the associated data source rather than selecting a different pre-defined data source. (Not a feasible solution IMO)



James Bailey has been trying to get answers.  
He reopened my incident and created another problem record, "PRB1151140", questioning why the proposed solution was so different than the documentation.