![]() The onReject script is useful for gathering information about the rejected record and storing it or reporting it back to the user. Once the script runs, the record is rejected and is not inserted into the target table. Since onReject runs before the record is rejected, the value of the fields in the source table can still be accessed and stored. In order for this script to run, “reject” has to be selected as the choice action for that field map. Summary: onReject runs before a record (often a referenced record) is rejected. Variables: source, target, map, action, log Similar to onForeignInsert, the onChoiceCreate script can take additional action when a new choice is created on a field. Because onChoiceCreate is a before action, only the source table record has set values. ![]() If it is not selected, the script will not run. Since this script runs when a choice is created, “create” has to be selected as the choice action for that field map. Summary: onChoiceCreate runs before a new choice is created on a choice field. An onAfter script might be a better option if that’s what you’re going for. ![]() There might be a way to do this, but I haven’t figured it out yet. When I was playing around with onForeignInserts, I couldn’t find a way to change values on the referenced table from my script. onForeignInsert scripts can manage what happens when a new record is added to a referenced table. The one being transformed, however, will not yet have a value. We also have access to the fields on the target table that have already been filled in. If “create” is not selected, the script will never run.Īt this point, we can access values on the source table. Since this script only runs on an insert, the choice action “create” has to be selected for that field map. Summary: onForeignInsert runs before a new referenced record is created. Variables: source, target, map, log, action, name, value, ignore, error This will modify the temperature value for every record. This is used when you want to change an individual field on each record. For example, if I had a Temperature field in my source table that was in Fahrenheit and I wanted it to be in Celsius on my target table, I would do the conversion in the field level source script. Summary: The source script replaces the source field in the field map. It gives the target field a value. Variables: source, target, answer, map, log, action If the value is invalid, the script can take action. onBefore scripts can be used to verify that the value of a source field is valid. This script runs for each individual record. If you want to set or alter values on the source table (see Temperature example explained in the Field Level Source Script section below) it can be done here. Summary: onBefore runs before every row is processed. Variables: source, target, import_set, map, log, action, ignore, status_message, error, error_message If you wanted to inform a user that more records were being imported, you could use the onStart script to send out the message that the import has started. If you try to access fields in the onStart script, the transform will not run. None of the fields can be accessed on the source or target tables since they have not been set up yet. ![]() Summary: onStart runs at the very beginning of the import before any of the records are processed. A list of all the variables and how they work can be found at the bottom of the post. Note: Only the variables listed above apply to the current script. Variables: source, import_set, map, log, ignore, error ![]() Each script will have another diagram that shows when they run. The following scripts are listed in the order that they execute in:īelow is a diagram of a sample import set. The following scripts are listed in the order that they execute in. I’ll just dive a little deeper into those concepts in this post. ServiceNow has some documentation on how to map with transform event scripts that I used as a reference while I was playing around with transform maps. In this post, I’ll go over the different types of scripts as well as the variables that are available to each one. Since there are so many different options for when to run a transform script, it can be difficult to determine what will work best for your application. ![]()
0 Comments
Leave a Reply. |