Exam MCD - Level 1 All QuestionsBrowse all questions from this 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.

    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
pgarciar

C is correct

Zumo

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

C is the correct Answer. Tested in Anypoint Studio

ck0241

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

edilberto1

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

Maddy_123

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

BankZenith

A is correct , mule soft trainer is answer me.

calazans

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).

october2

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

kimbi

Anser is A

Alandt

A is the correct answer, ignore my other comment.

Alandt

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.

Serjp3

"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

ExamDev

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

That's what I thought too! thanks

ExamDev

C!!!!!

Damster_99

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

malakas1231

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. "

frediepulgoso

A is correct