Skip to Content

MapWithDefault for empty elements

Hello all,

I have a question regarding mapWithDefault function:

If I have an empty source field, the mapWithDefault does not seem to work. It only works if the source field is not existing. E.g:

Mapping:

source field a -> mapWithDefault('Test') -> target field a

Test for empty field:

Source:

<a></a>

Result:

<a></a>

Test with removed field:

Source:

Result:

<a>Test</a>

What I would like is to have the mapWithDefault value also for empty fields (so the first example above should also create <a>Test</a> as the output). What is the best way to achieve this? I know it works with an IF condition which checks for the empty value specifically, but maybe there is a better option?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 29, 2016 at 08:13 AM
    • One alternate to this could be to use FixValues, where you can set empty value as source and target as "test"
    • And select the copy source value if not found option..

    Regards

    Bhavesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 29, 2016 at 08:38 AM

    Thank you, following the fixValue approach as it is more lightweight than the IF approach (which I've used before as well).

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.