- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:02 AM
Hi guys,
Does anybody have a script to create data source record?
I found the following but it should be modified
var type = {};
type.schedule = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Display name for scheduled import -- eb9f2dae6f46a60051281ecbbb3ee4a5
type.table = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Import table name
gs.log('0. Process File Start');
if(type.schedule != '' && type.table != '') {
gs.log('1. Setting up data source');
current.name = type.schedule + '_' + gs.nowDate(); //append date time to name of data source for audit
current.import_set_table_name = type.table;
current.import_set_table_label = "";
current.type= "File";
current.format = "CSV"; //"Excel CSV (tab)";
current.header_row = 1;
// current.file_retrieval_method = "Attachment";
current.file_retrieval_method = "HTTPS";
current.data_source.url = "storage.googleapis.com";
current.pathParams.url = "/gcp_bucket_ca/sobject_test_export3.csv";
var myNewDataSource = current.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:19 AM
Please post your actual requirement / issue to address it.
Made changes that creates the data source record
var gr = new GlideRecord("sys_data_source");
gr.initialize();
var type = {};
type.schedule = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Display name for scheduled import -- eb9f2dae6f46a60051281ecbbb3ee4a5
type.table = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Import table name
gs.log('0. Process File Start');
if (type.schedule != '' && type.table != '') {
gs.log('1. Setting up data source');
gr.name = type.schedule + '_' + gs.nowDate(); //append date time to name of data source for audit
gr.import_set_table_name = type.table;
gr.import_set_table_label = "";
gr.type = "File";
gr.format = "CSV"; //"Excel CSV (tab)";
gr.header_row = 1;
// current.file_retrieval_method = "Attachment";
gr.file_retrieval_method = "HTTPS";
gr.scp_server = "storage.googleapis.com";
gr.file_path = "/gcp_bucket_ca/sobject_test_export3.csv";
var myNewDataSource = gr.insert();
gs.print(myNewDataSource);
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:19 AM
Please post your actual requirement / issue to address it.
Made changes that creates the data source record
var gr = new GlideRecord("sys_data_source");
gr.initialize();
var type = {};
type.schedule = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Display name for scheduled import -- eb9f2dae6f46a60051281ecbbb3ee4a5
type.table = 'u_imp_tmpl_u_term_phr_empl_mvs_ids'; //Import table name
gs.log('0. Process File Start');
if (type.schedule != '' && type.table != '') {
gs.log('1. Setting up data source');
gr.name = type.schedule + '_' + gs.nowDate(); //append date time to name of data source for audit
gr.import_set_table_name = type.table;
gr.import_set_table_label = "";
gr.type = "File";
gr.format = "CSV"; //"Excel CSV (tab)";
gr.header_row = 1;
// current.file_retrieval_method = "Attachment";
gr.file_retrieval_method = "HTTPS";
gr.scp_server = "storage.googleapis.com";
gr.file_path = "/gcp_bucket_ca/sobject_test_export3.csv";
var myNewDataSource = gr.insert();
gs.print(myNewDataSource);
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 06:31 AM
Thanks a lot for help!!