Would like to check the value of another field (extracted previously) and based on the value, either set the new field to nothing “” or to return the new value.
if (record.fields.CODE == 'S'){
//return empty value
} else {
//return extracted value
}
Probably don’t need the else
if (record.fields.CODE == 'S'){
//return empty value
}
I assume that you would like to apply the JavaScript code to assign a value to a Field extracted by a Extract Step, is it not? Should this be correct then I assume that you have to use the following JavaScript code instead:
var result = "";
if (record.fields.CODE !== "S") {
result = "Example";
}
result;
What I’m looking for is if record.fields.HOURLY_SALARIED_CODE equals ‘S’ then I want to replace the extracted value with zero or empty value, but otherwise if record.fields.HOURLY_SALARIED_CODE is anything else to keep the extracted value.
I’m working on another approach which is partially working.
Added an action script.
I completely missed that I was passing a string instead of the number.
After removing them this now appear to work in the datamapper design view.
Still need to test all the way to output.
My 3 field definitions are already using javascript to build the values.
They threw this twist at the last moment, so I’m going with the action script because I suspect their might me more. I can then control them all at the same location instead of on each field definition.
In case you want to avoid scripting you could also use a Condition step and set the value of the EARNINGS_HOURS to 0 or null in one branch and extract the actual value in the other. Not sure if this is helpful but thought it was worth sharing.