How to blank out fields depending on the value of another field via a transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 06:35 AM
In the below form, the question '
However, I'm wanting to do this in a transform map so that if a user enters 'No' in a spreadsheet for that question, but they fill in the other 5 questions without knowing it, the transform map needs to blank out those 5 questions when the import has been completed.
I was just wondering if this is possible to do.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 07:47 AM
Hello Matthew,
1. You can use the script type in field mapping for those 5 field to validate if the value of your variable is Yes or No and then set the value in those 5 field:
field 1:
answer = (function transformEntry(source) {
var ratesFactors = source.rates_factors;
if (ratesFactors && ratesFactors.toLowerCase() == "yes") {
return source.field1_name;
} else {
return "";
}
})(source);
Similarly use [script] in field mapping for other 4 fields as well and use similar script to return the value.
2. Other option is to use the onBefore transform script and you can remove the field mapping for those 5 fields:
var ratesFactors = source.rates_factors;
if (ratesFactors && ratesFactors.toLowerCase() == "yes") {
target.field1_name = source.field1_name;
target.field2_name = source.field2_name;
target.field3_name = source.field3_name;
target.field4_name = source.field4_name;
target.field5_name = source.field5_name;
} else {
target.field1_name = "";
target.field2_name = "";
target.field3_name = "";
target.field4_name = "";
target.field5_name = "";
}
If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 12:56 AM
Hello
Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.
Thanks