Flow Designer Action - Blank Output for getUniqueValue on GlideImportSetLoader

Peter525
Tera Expert

Hello -

I'm getting a blank output for importSetSysID using the script below when it's run inside a Flow Designer action. I tried outputting other values via getValue, but those are also coming up blank.

(function execute(inputs, outputs) {
var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(inputs.dataSource);
var ranload = loader.loadImportSetTable(importSetRec, inputs.dataSource);
importSetRec.state = "loaded";
importSetRec.update();

outputs.importSetSysID = importSetRec.getUniqueValue();

})(inputs, outputs);

Any suggestions?

1 ACCEPTED SOLUTION

Ethan Davies
Mega Sage
Mega Sage

Hey @Peter525 ,

I have run your code in isolation on my PDI with a Data Source (Excel type) with a File Attached to it. Using the code below I had no problem running the code and also outputting the info message with the unique value:

try {
    var grDataSource = new GlideRecord('sys_data_source');
    if (grDataSource.get('35f18678978911102d2a38271153af84')) {
        var loader = new GlideImportSetLoader();
        var importSetRec = loader.getImportSetGr(grDataSource);
        var ranload = loader.loadImportSetTable(importSetRec, grDataSource);
        importSetRec.state = "loaded";
        importSetRec.update();
        gs.addInfoMessage('Unique value is: ' + importSetRec.getUniqueValue());
    }
} catch (err) {
    gs.addErrorMessage(err);
}

I suspect the issue is with the configuration of the Data Source you are trying to use, with that in mind I have some considerations for you that may lead to solving the issue:

  1. Make sure the Data Source you are using has a corresponding Import Set Table Name value so the data can be transformed after being loaded.
  2. Make sure that the Data Source value that you are passing to the loader.getImportSetGr and loader.loadImportSetTable functions is a GlideRecord and not a sys_id.
  3. Ensure that your Data Source is actually pulling or contains data. Is there a missing attachment? Does the Data Source actually pull data when you test it?
  4. If you are working in a Scoped Application, you may need to grant cross scope access to the GlideImportSetLoader to your custom scope to global.
  5. IMPORTANT: Make sure that your Flow Action that you are calling this script in actually has importSetSysID registered as an Output at the end of the Flow Action (not just in the script execution step), otherwise nothing will be returned from your action despite you creating an output in your script step.

Let me know how you get on!

Please mark this answer as correct or helpful if it aided in solving your issue, thanks!

View solution in original post

3 REPLIES 3

Ethan Davies
Mega Sage
Mega Sage

Hey @Peter525 ,

I have run your code in isolation on my PDI with a Data Source (Excel type) with a File Attached to it. Using the code below I had no problem running the code and also outputting the info message with the unique value:

try {
    var grDataSource = new GlideRecord('sys_data_source');
    if (grDataSource.get('35f18678978911102d2a38271153af84')) {
        var loader = new GlideImportSetLoader();
        var importSetRec = loader.getImportSetGr(grDataSource);
        var ranload = loader.loadImportSetTable(importSetRec, grDataSource);
        importSetRec.state = "loaded";
        importSetRec.update();
        gs.addInfoMessage('Unique value is: ' + importSetRec.getUniqueValue());
    }
} catch (err) {
    gs.addErrorMessage(err);
}

I suspect the issue is with the configuration of the Data Source you are trying to use, with that in mind I have some considerations for you that may lead to solving the issue:

  1. Make sure the Data Source you are using has a corresponding Import Set Table Name value so the data can be transformed after being loaded.
  2. Make sure that the Data Source value that you are passing to the loader.getImportSetGr and loader.loadImportSetTable functions is a GlideRecord and not a sys_id.
  3. Ensure that your Data Source is actually pulling or contains data. Is there a missing attachment? Does the Data Source actually pull data when you test it?
  4. If you are working in a Scoped Application, you may need to grant cross scope access to the GlideImportSetLoader to your custom scope to global.
  5. IMPORTANT: Make sure that your Flow Action that you are calling this script in actually has importSetSysID registered as an Output at the end of the Flow Action (not just in the script execution step), otherwise nothing will be returned from your action despite you creating an output in your script step.

Let me know how you get on!

Please mark this answer as correct or helpful if it aided in solving your issue, thanks!

Peter525
Tera Expert

I created a new variable in the Output and renamed it in the script. Not sure why it wasn't working before but everything is fine now. Thanks for the suggestion Ethan!

Could you add screenshots of the inputs, script step and outputs? I am still having the same original issue as you where I get a error: java.lang.NullPointerException