Load data into table on UI action

Supriya Waghmod
Kilo Contributor

How we can load , data on UI action .

Data source, Transform map created to transfrom,

On form - UI action is added.

Issue- 1.How to check attachment added on click of UI action ?

            2. How to load data on Click to target table

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Super 

Refer my blog

Something similar to that you can use and enhance it as per your need

Data load and transform via Catalog Item

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@Super 

Refer my blog

Something similar to that you can use and enhance it as per your need

Data load and transform via Catalog Item

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Supriya Waghmod
Kilo Contributor

Thanks its helpful.

 

But in my case , its custom table form -- I am adding attachment on it.

 

How do I attach the workflow - on which condition ??

Hi,

Since that is your custom table and attachment you can use that same script in the UI action itself

your UI action code would look something like this

GlideSysAttachment.copy(current.getTableName(), current.sys_id, 'sys_data_source', '<dataSourceSysId>');

var exportGr = new GlideRecord("scheduled_import_set");
exportGr.addQuery("sys_id", "<RecordSysId>"); // sys_id of the record which you will be creating for scheduled import in step (a)
exportGr.query();
if (exportGr.next()) {
gs.executeNow(exportGr); // this is for scoped app
// SncTriggerSynchronizer.executeNow(schImp_GR); // this is for non scoped app
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Now attachment , attached to Data source while auto load but tranformation process not happing.

 

Do I need to timer kind of think?? Or I missed any think

 

Ui action Script:

 

function importQC(){


var answer = confirm('Have you attached spreadsheet');
if(answer==true)
{
gsftSubmit(null, g_form.getFormElement(), "fj_import_qc");
}

}

var gr2 = new GlideRecord("sys_attachment");
gr2.addQuery("table_sys_id", current.sys_id);
gr2.addQuery("table_name", "x_fdrbl_business_p_bpm_task");
gr2.query();
if (!gr2.next()) {
gs.addErrorMessage("You must attach a file to submit. Your import submission has been aborted.");
current.setAbortAction(true);
}
else{

GlideSysAttachment.copy(current.getTableName(), current.sys_id, 'sys_data_source', 'a5226c1e1b7f181069e7a9342a4bcbdf');

var exportGr = new GlideRecord("scheduled_import_set");
exportGr.addQuery("sys_id", "bd553cf2db7f9810b22061f74b9619ec"); // sys_id of the record which you will be creating for scheduled import in step
exportGr.query();
if (exportGr.next()) {
//gs.executeNow(exportGr); // this is for scoped app
SncTriggerSynchronizer.executeNow(schImp_GR); // this is for non scoped app
}
}

Hi,

Yes I think after adding the attachment kindly add wait for 5 seconds

updated script

function importQC(){


var answer = confirm('Have you attached spreadsheet');
if(answer==true)
{
gsftSubmit(null, g_form.getFormElement(), "fj_import_qc");
}

}

var gr2 = new GlideRecord("sys_attachment");
gr2.addQuery("table_sys_id", current.sys_id);
gr2.addQuery("table_name", "x_fdrbl_business_p_bpm_task");
gr2.query();
if (!gr2.next()) {
gs.addErrorMessage("You must attach a file to submit. Your import submission has been aborted.");
current.setAbortAction(true);
}
else{

GlideSysAttachment.copy(current.getTableName(), current.sys_id, 'sys_data_source', 'a5226c1e1b7f181069e7a9342a4bcbdf');

var ms = 5000; // 5 seconds

var endSleep = new GlideDuration().getNumericValue() + ms;
while ( new GlideDuration().getNumericValue() < endSleep) {
//wait
}

var exportGr = new GlideRecord("scheduled_import_set");
exportGr.addQuery("sys_id", "bd553cf2db7f9810b22061f74b9619ec"); // sys_id of the record which you will be creating for scheduled import in step
exportGr.query();
if (exportGr.next()) {
//gs.executeNow(exportGr); // this is for scoped app
SncTriggerSynchronizer.executeNow(schImp_GR); // this is for non scoped app
}
}

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader