Exam MCD - Level 1 All QuestionsBrowse all questions from this exam
Question 134

A Mule project contains a DataWeave module file WebStore.dwl that defines a function named loginUser. The module file is located in the project’s src/main/resources/libs/dw folder.

What is correct DataWeave code to import all of the WebStore.dwl file’s functions and then call the loginUser function for the login “[email protected]”?

    Correct Answer: C

    To import all the functions from a specific DataWeave module and call a function from it, you should use the correct namespace and syntax. The correct import statement should specify the full path of the module with double colons (::). Once the module is imported, you can directly call the function without specifying the module name again. Therefore, the correct answer is to use 'import * from libs::dw::WebStore' and then call 'loginUser' directly.

Discussion
RanjansinghOption: C

The wild card import lead to import all functions from the .dw file and no need to refer the file again.

[Removed]Option: C

Looks like C https://docs.mulesoft.com/dataweave/2.4/dw-functions

AlandtOption: C

ChatGPT: C. import * from libs::dw::WebStore --- loginUser( “<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="35565c5b514c1b4554475e75504d54584559501b565a58">[email protected]</a>” )

ExamDevOption: C

Example: Importing and Using a Custom DataWeave Module %dw 2.0 import modules::MyModule output application/json --- MyModule::myFunc("dataweave") ++ "name" Here we are talking about custom modules!

ExamDev

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. For example, this import directive does not identify any functions to import from the String module, so it calls the pluralize function like this: Strings::pluralize("box").

hahahe234Option: C

I agree with C