Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

transform map script does not run?

arawat
Kilo Contributor

Hi All,

I am trying to create an inbound web service which has a 'onBefore' transform script. I want to use it to filter input for my target table. But from whatever little I know, it seems the script is not executing. Enabling all debugging, I see some errors.

I see a lot of these -

05:03:20.747: Attempted script access to inaccessible member denied - com.glide.script.ElementDebugMessage:getType:()Ljava/lang/String

& some of these -

05:03:20.756: App:Dashboards TIME = 0:00:00.000 PATH = ui_action/a315c1539f0120007aaa207c7f4bccff/execute CONTEXT = onBefore RC = false Rule =

ui_action/a315c1539f0120007aaa207c7f4bccff/execute

I have no idea what they mean. My script is as follows:

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

  // Add your code here

  var user = source.u_user_name;

  var id = source.u_id;

  gs.log('Adding row for agent id ' + id, 'TransformMap');

  var querystring = 'user=' + user + '^ORusernamealias=' + user;

  var mem = new GlideRecord('x_91069_das_members');

  mem.addEncodedQuery(querystring);

  mem.setLimit(1);

  mem.query();

  if (mem.next()) {

  if (mem.type != 'AGENT') {

  ignore = true;

  gs.log('Import row for non-agent id ' + id + 'ignored.', 'TransformMap');

  }

  else {

  gs.log('Import row for agent id ' + id + 'added.', 'TransformMap');

  }

  }

  else {

  gs.log('Import row for unknown id ' + id + 'added.', 'TransformMap');

  }

})(source, map, log, target);

Any idea what am I doing wrong here?

Thanks.

1 ACCEPTED SOLUTION

You need to go to System Import Sets -> Transform History and select your related import set. It would contain the logs added by log.function();



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


View solution in original post

8 REPLIES 8

arawat
Kilo Contributor

Never mind. Seems like gs.log and gs.print are not available in transform map scripts.


Hi Anshuman,



In a transform map script, you need to use log.info() , log.warn() and log.error()



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Thanks for that. However, where do these get printed? I have enabled all logging, but it doesn't contain my logs.


You need to go to System Import Sets -> Transform History and select your related import set. It would contain the logs added by log.function();



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response