New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE

Launch unload from JS or other way

Hello experts,

I have a following task: we have a table where we store filenames and queries for objects that are being modified by us. What I need to do is: when a record to our modified_objects_table is being added i need to create a unl-file of the record. For example, our modified_objects_table has two fields: "filename" and "query". And my script should create an unl-file that would contain the record(s) selected by "query" from "fielname" table.

I tried to use us.unload.process RAD for this, but got the following error:

"The unload could NOT be created in the path/filename specified.  Either the correct config record is missing, the path (or folder) does not exist, or there is an access problem.
Application: file.unload, has completed with errors, check other messages.  26/09/17 18:10:12"

Any ideads how to bypass this error? Or maybe there are other ways to accomplish this?

16 Replies
Vice Admiral Vice Admiral
Vice Admiral

Hi @Nick_Karpushkin,

sorry for the delay.

Just to be sure that I'm understood your requirement:

You have a table "modified_objects".
This table includes the fields "" and "unique.key".

Now an user creates for example a new ScriptLibrary record.
After clicking the "Add" button, the system should create an unload file.

The unloads looks something like this:
Unload Name: Modified Object - <SLNAME> - <Operator> - <TIMESTAMP>
Unload Lines:
* Name: ScriptLibrary
* Query: name="<SLNAME>"

When you say: "...and attach the created unl-file to the record that user is currently adding."

Do you mean, append the created unload as attachment to the current record (=ScriptLibrary) or should the attachment appended to your "modifed_objects" record?



Hi @MarcusReinhardt,

Yes, you did understand everything correctly. The created unl-file should be attached to the "modifed_objects" record.

Sorry for the delay, I really didn't expect anyone to answer.

Vice Admiral Vice Admiral
Vice Admiral

Hi @Nick_Karpushkin,

i have a idea how to solve this, but didn't tested it.

The idea is the following:

User created/updated a record (e.g. ScriptLibrary).
Via a trigger record, a script will be executed, which generates directly a unload record ( i think, we can use the existing schedule script (see above)).

The created unload has as name the following structure "<timestamp>_<tablename>_<objectname>.unl" (example: 1020393211_ScriptLibrary_MyAwesomeLibrary.unl) and will be saved temporary in the RUN directory in a subdirectory named "modified_objects_unloads".

After the unload will is saved on the HDD, a second script will attached it to the related modified_objects table.

If everything works as expected, the created unload file on the HDD will be deleted.


I hope i can find some time to test this idea 🙂 

Maybe you have already a alternative solution to solve it.





Hopefully I'll have time to test it later, 'cause now I'm really busy. But thanks for your efforst anyway!

Vice Admiral Vice Admiral
Vice Admiral




var $ = system.library.c.$;

 * Creates a scheduler record to export records
 * via the unload utilities.
 * @author     Marcus Reinhardt,
 * @example
 * var $                = system.library.c.$;
 * //var fRevisionRecord  = $('myrevisiontable').select('').uniqueResult();
 * var fRevisionRecord = {
 * 	'query' : 'name="mr_test_library"',
 * 	'tablename' : 'ScriptLibrary'
 * };
 * var res   = system.library.mr_test.createUnloadViaScheduler( fRevisionRecord );
 * print( res );
 * @param      {SCFile}   fTable  The file
 * @return     {boolean}
function createUnloadViaScheduler(fTable){
    var nTimestamp = new Date().getTime();  
    var cTargetFile = "C:/unloads/" +nTimestamp + "_" + fTable['tablename'] + ".unl";

    var fSchedule           = new SCFile("schedule");
    //we have to use the current operator as class name
    //otherwise the user will lose their permissions in case
    //when you're using "linker" or some other background process as class name
    fSchedule._class        = system.functions.operator();
    //fSchedule._class		= 'linker';
    fSchedule.expiration    = new Date('2100/01/01 00:00:00');
    fSchedule.application   = "unload.background";
    fSchedule.strings[0]    = 'append';
    fSchedule.strings[10]   = 'winnt';
    fSchedule.strings[11]   = 'binary';
    fSchedule.strings[12]   = 'create';
    fSchedule.strings[13]   = 'update';
    fSchedule.strings[15]   = 'false';
    fSchedule.strings[16]   = 'false'
    fSchedule.strings[2]    = cTargetFile;
    fSchedule.strings[3]    = fTable['query'];
    fSchedule.strings[4]    = fTable['tablename'];          = "unload file for "+fTable['tablename']+" with query "+fTable['query'];      
    var rcInsert = fSchedule.doInsert();
    var objParameter = {"file": fSchedule, 'name' : system.functions.operator()};
	var results = $.callradByRef("scheduler.process", objParameter, false);
 	return results; 


i have simulated the SCFile with an simple JS Object, because it basicly the same.

The execution was successfully on server side. The created scheduler was processed successfully (means here, that the schedule record was deleted) and the defined unload was in the "C:/unloads" directory.

But on client side (running the JS from another client) I got always a error message that the script wasn't able to find the defined target directory.

I have also checked the existing applications, because there are some other applications to create an unload, but nothing was working (or maybe I used the wrong parameters).

For my other tests, I used the following snippet.

var params = [
        system.library.ScAPI_RAD.input_Array('values', ['Underscore']),
        system.library.ScAPI_RAD.input_String('file', 'ScriptLibrary'),
        system.library.ScAPI_RAD.input_String('name', 'name'),
var results = system.library.ScAPI_RAD.invokeRAD('unload.records',params);

Hmmm.. currently I'm out of ideas... but maybe find something with this snippets 🙂

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.