The CreatorCon Call for Content is officially open! Get started here.

Logging transform map custom errors on onBefore script.

rai5
Mega Guru

Hello,

 

I am able to log custom errors during the import process but, somehow I cannot associated them with the import set.

 

Here is code similar to what I am using.

 

 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    var importSetRun = new GlideImportSetRun();
    var importLog = new GlideImportLog(importSetRun, 'My Source');



    if (<condition>) {
        
        return string;
        
    } else {
        ignore = true;
        importLog.error( "Custom error log here");
        
    }

})(source)

 

 

 

What am I missing in order t o associate this log to the import set so I can easily see the errors by simply navigating to the import log related list of the import set?

 

3 ACCEPTED SOLUTIONS

Ben_G
Tera Expert

You can just use the 'log' variable that is up in the runTransformScript function.

 

Generally the GlideImportLog API would be used when you are starting an import from a script outside of an import set.

 

See Transformation script variables for more info on the other variables.

View solution in original post

Hi BP,

 

When using the log.error that is part of the function it does not log anything at all, using the GlideImportLog  does log errors but I would like to know how to associate it with the import set.

View solution in original post

rai5
Mega Guru

Found the solution. While copying an pasting from other transform scripts I did not pay attention to the last line of the script which was missing parameters. The code bellow works. Turns out I did not have to use the GlideImportSetRun().

 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here

    if (<condition>) {
        
        return string;
        
    } else {
        ignore = true;
        log.error( "Custom error log here");
        
    }

})(source, map, log, target)

 

 

View solution in original post

3 REPLIES 3

Ben_G
Tera Expert

You can just use the 'log' variable that is up in the runTransformScript function.

 

Generally the GlideImportLog API would be used when you are starting an import from a script outside of an import set.

 

See Transformation script variables for more info on the other variables.

Hi BP,

 

When using the log.error that is part of the function it does not log anything at all, using the GlideImportLog  does log errors but I would like to know how to associate it with the import set.

rai5
Mega Guru

Found the solution. While copying an pasting from other transform scripts I did not pay attention to the last line of the script which was missing parameters. The code bellow works. Turns out I did not have to use the GlideImportSetRun().

 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here

    if (<condition>) {
        
        return string;
        
    } else {
        ignore = true;
        log.error( "Custom error log here");
        
    }

})(source, map, log, target)