How to create a module that points to a specific "Import Set table" in Load Data

Paulo Machado
Kilo Sage

Hi folks,

I need to create a new module that directs the user to a specific data source and loads a particular Import Set table.

Unfortunately, it’s not possible to pass parameters to the Data Source page. It works on the Edit module page, but not on the Data Source page.

I’m considering creating a new table with an attachment field and a Business Rule to automatically run the data source.
I’d like to know if there’s an easier or alternative way to implement this functionality, or if creating a new table is indeed the best approach.

Thanks in advance.

1 ACCEPTED SOLUTION

@lauri457 

I agree your solution will also help but it's a customization which can be avoided by simply training the users on how to use the OOTB Load Data module.

Having customization will involve maintaining the code over period of time during upgrades.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

8 REPLIES 8

lauri457
Giga Sage

There are two user preferences that control the radio button and table selected when you open the page.

import.import_set_tablename   //staging table name
import.import_action          //value: "use_table" to select Existing table

 
I tested this by creating a ui page with below client script that sets the import.import_set_tablename user prop with fetch and the graphql mutation for user preferences. After the user pref is changed the custom ui page redirects to the ui page for the load data module. 

(function () {
	const graphapi = '/api/now/graphql',
		token = window.g_ck;

	const query = `
mutation {
  now {
    userPreference {
      updateUserPreference(name:"import.import_set_tablename", value: "imp_notification") {
        name
        value
      }
    }
  }
}
`;

	fetch(graphapi, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json',
			'X-UserToken': token
		},
		body: JSON.stringify({ query })
	})
		.then(response => {
			if (response.ok) {
				window.location.href = '/nav_to.do?uri=create_import_set.do';
			}
		})
		.catch(error => {
			console.error('error:', error);
		});
})()

You'd also want to set the import.import_action preference as well so that the existing table is chosen

 

This file has the scripts for the page so you could potentially do it with ui scripts as the functions will be available in the gsft_main iframe

/scripts/create_import_set.jsx 

Ankur Bawiskar
Tera Patron
Tera Patron

@Paulo Machado 

I won't recommend this customization.

Train your admin or import admins to use Load Data module in left nav and then they can select the import set table and attach file and then transform the data.

It's part of user training

AnkurBawiskar_0-1761023374896.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

If you are referring to my solution above. Why do you not recommend this? It is minimally intrusive as it sets user preferences and redirects to a page. It wouldn't change anything in the original functionality. I can see the process perspective but just curious what crosses the line with this?

If he is considering a custom table for this it might see enough use that it could even make sense in ROI terms to create something similar to the ASN import ui page in HAM. 
Use Advanced Shipment Notification

lauri457_0-1761027045440.png

There are also oob/community flows/actions to import data from files too so one could even link the module to a catalog item using a portal page in /swp or the legacy catalog in next experience and achieve this with no/low-code.

@lauri457 

I agree your solution will also help but it's a customization which can be avoided by simply training the users on how to use the OOTB Load Data module.

Having customization will involve maintaining the code over period of time during upgrades.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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