MCD - Level 1 Exam QuestionsBrowse all questions from this exam

MCD - Level 1 Exam - Question 99


A Mule project contains a DataWeave module called MyModule.dwl that defines a function named formatString. The module is located in the project's src/main/ resources/modules folder.

What is the correct way in DataWeave code to import MyModule using a wildcard and then call the module's formatString function?

A.

B.

C.

D.

Show Answer
Correct Answer:

The correct way to import a module in DataWeave using a wildcard and call the module’s function without needing to prefix it with the module's name is to use the import * from syntax. After importing the module this way, functions within the module can be called directly without specifying the module name. Therefore, the correct answer is to import the module using a wildcard and call formatString directly. This is depicted in option D: %dw 2.0 output application/json import * from modules.MyModule --- formatString( "annie point" ).

Discussion

15 comments
Sign in to comment
pgarciar
Mar 29, 2021

C is correct

Zumo
May 29, 2021

C is not the Correct Answer. Reference : https://docs.mulesoft.com/mule-runtime/4.3/dataweave-create-module#using-a-mapping-file-in-a-dataweave-script Example from above URL is as follows: %dw 2.0 import modules::MyMapping output application/json --- MyMapping::main(payload: { "user" : "bar" }) ----------------------- Correct Answer would be Option 'A'

Damster_99
Aug 28, 2023

C is the correct Answer. Tested in Anypoint Studio

ck0241
Jul 21, 2021

C is the correct answer since we are importing myModule using wildcard.

edilberto1
Aug 2, 2021

Totally Agree, referring to above documentation (https://docs.mulesoft.com/mule-runtime/4.3/dataweave-create-module#using-a-mapping-file-in-a-dataweave-script), it said that if you import using the * setting the name front the function is not required, So Right Answer is C

october2
Aug 31, 2021

A may be the right answer. ----- If the directive does not list specific functions to import or use * from to import all functions from a function module, you need to specify the module when you call the function from your script. ---- https://docs.mulesoft.com/mule-runtime/4.2/dw-functions

calazans
Jan 6, 2022

C is correct https://docs.mulesoft.com/dataweave/2.2/dataweave-create-module There are several ways to import a module or elements in it: Import the module, for example: import modules::MyModule. In this case, you must include the name of the module when you call the element (here, a function) in it, for example: MyModule::myFunc. Import all elements from the module, for example: import * from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works. Import specific elements from a module, for example: import myFunc from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works. You can import multiple elements from the module like this, for example: import myFunc someOtherFunction from modules::MyModule (assuming both myFunc and someOtherFunction are defined in the module).

BankZenith
Mar 18, 2022

A is correct , mule soft trainer is answer me.

Maddy_123
Mar 14, 2023

C is correct. https://apisero.com/import-a-function-module-in-dataweave/

frediepulgoso
Mar 8, 2022

A is correct

malakas1231
Aug 24, 2023

A is correct. Look at this from official mulesoft docs: https://docs.mulesoft.com/dataweave/2.4/dw-functions "The way you import a module impacts the way you need to call its functions from a DataWeave script. If the directive does not list specific functions to import or use * from to import all functions from a function module, you need to specify the module when you call the function from your script. "

Damster_99
Aug 28, 2023

C is the correct Answer https://imgur.com/a/vK8L2CP Is the only flow that compiled without error and works.

ExamDev
Jan 22, 2024

C!!!!!

ExamDev
Jan 25, 2024

A is the correct answer because they are talking about CUSTOM modules. !!!!!!! VERIFIED IN THE Anypoint Studio. (I was wrong with my previous post)

Alandt
Feb 7, 2024

That's what I thought too! thanks

Serjp3
Jan 29, 2024

"Import all elements from the module, for example: import * from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works." - https://docs.mulesoft.com/dataweave/latest/dataweave-create-module

Alandt
Feb 5, 2024

ChatGPT: The correct answer is Option C: This option correctly imports all functions from MyModule and allows you to call formatString directly, without needing to prefix it with the module name.

Alandt
Feb 7, 2024

A is the correct answer, ignore my other comment.

kimbi
Mar 13, 2024

Anser is A