MCD - Level 1 Exam QuestionsBrowse all questions from this exam

MCD - Level 1 Exam - Question 71


Refer to the exhibits.

The Set Payload transformer's value is set to {`˜year': `˜2020'}.

What message value should be added to the Logger component to output the message `˜The year is `˜2020', without hardcoding 2020?

Show Answer
Correct Answer: D

To output the message 'The year is 2020' without hardcoding the year value, the correct syntax in the MuleSoft Logger component should utilize DataWeave expression language. The expression that concatenates a string with a payload field is written using '#[]', with the variable expression inside the brackets. The correct format for achieving this is '#["The year is " + payload.year]'. This will dynamically fetch the 'year' value from the payload and concatenate it into the string, resulting in the desired output.

Discussion

5 comments
Sign in to comment
calazansOption: A
Jan 6, 2022

A is correct

sshams2021Option: A
Jan 24, 2022

"The year is #[payload.year]"

mubashirhassan2030Option: A
Nov 27, 2021

Refer to the exhibits. The Set Payload transformer's value is set to {`˜year': `˜2020'}. What message value should be added to the Logger component to output the message `˜The year is `˜2020', without hardcoding 2020? A. "The year is #[payload.year]" B. "#[The year is $(payload.year)]" C. "#["The year is ++ payload.year"]" D. "#["The year is " + payload.year]"

peeman004Option: A
Oct 27, 2023

Funny enough, I tried it and it seems both A and B seems to work. A is not the most natural thing though -- as you typically click on the FX button and that put the brackets around the whole expression.

peeman004
Oct 27, 2023

No, I'm wrong -- B only works with quotes around: message='#["The year is $(payload.year)"]' but that's not in the option. Sorry for confusion...

ExamDevOption: A
Jan 22, 2024

"The year is #[payload.year]"