Transform Map onAfter Script check for target field is null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 01:06 PM
Running an onafter transform script and trying in one function to only populate a reference field on an existing record if it is null (there is other code above that function that sets the field). What is the correct way to do this in an onafter script?
For example
if (target.field. == ' ' ){
then do something
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 01:30 PM
You have an extra dot on the end of field. That might be a transposition error.
You can try target.field.nil(), or !target.field.hasValue(), but target.field == '' should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 02:15 PM
That was a typo. Thanks. Also quick question how can i reference undefined, is it undefined or 'undefined' in quotes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 02:29 PM
In the system OOB, there is both:
if (choice.sys_id != undefined) {
and
if(typeof field != 'undefined') {
So, it looks as though if you are directly referencing the result, it is without ticks, but if you are looking at the type of the field, it is with ticks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 01:52 PM
Something like this will act strong.
if(JSUtil.nil(target.getValue('field'))){
// then do something
}