Posts

Showing posts with the label Mule4

DB Update Statement with In Clause in Mulesoft

Image
 Here we will look at how Update SQL query with IN clause can be constructed when there are multiple values coming as array as IN clause input Assuming that dateSent must be updated for all the eventIds sent as input using IN clause. Input: { "dateUpdated" : "2025-01-14" , "eventId" : [ "234er-4356" , "234er-4896" , "4dse4-4321" ] } Building Update SQL in Dataweave %dw 2.0 output application/json --- { "dynamicUpdateStatement" : "Update table_name set dateSent='" ++ payload . dateUpdated ++ "' where eventId in (" ++ "'" ++ (payload . eventId joinBy( "','" ) ++ ")" ) } Output: { "dynamicUpdateStatement" : "Update table_name set dateSent='2025-01-14' where eventId in ('234er-4356','234er-4896','4dse4=4321')" } Screenshot: Another Solution: Dataweave: %dw 2.0 output application/json ---...

RAML with MultiPart

 Lets build to build file upload with MultiPart, below is RAML RAML /testUpload:      post:        description:  file upload to sftp        headers:         f ilePath:            description:  sftp file path            type:  string        body:          multipart/form-data:            properties:              fileName:                description:  file name                type:  string  ...

Dataweave 2.0 update function

Image
  Update the user data below. Usernames should be all lower case and the street should be   "Fiskargatan" (example from dataweave tutorial from mulesoft) Input payload { "username": "WASP", "name": "Lisbeth", "surname": "Salander", "location": { "address": { "street": "Lundagatan", "number": 9 }, "city": "Stockholm", "country": "Sweden" } } Dataweave Transformation %dw 2.0 import * from dw :: util :: Values output json --- payload update "username" with lower($) update [ "location" , "address" , field( "street" )] with "Fiskargatan" output { "username" : "wasp" , "name" : "Lisbeth" , "surname" : "Salander" , "location" : { "address...

Dataweave 2.0 - Pluck

Image
 Pluck is useful converting HashMap/Object into array of Objects.  pluck  iterates over an object and returns an array of keys, values, or indices from the object.

Dataweave 2.0(2.7) - typeOf

Image
 How to determine if the variable or payload type is String, Array, Number , Boolean or Object  using typeOf Object: String Number: Boolean: Array:

Mule4 - Resolving Database Date and DateTime Type Error while Inserting.

Let's see how to resolve error while inserting database date and datatime errors in Mule4 while inserting data into database. Column Declared as Date in database for the table example as follows: TRANDATE DATE DEFAULT '1970-01-01' NOT NULL, Dataweave : ( assuming the incoming  billing_date is coming as DateTime( example: "2024-02-06T11:02:05.237Z") and converting to Date in String format "yyyy-MM-dd" %dw 2.0 output application/json --- "billing_date": $.billing_date as DateTime {format: "yyyy-MM-dd'T'HH:mm:ss.SSSX"} as String {format : "yyyy-MM-dd"} , to convert RAML datetime type DB date time %dw 2.0 output application/json --- "date_updated" : $.date_updated as DateTime {         format : "yyyy-MM-dd'T'HH:mm:ss.SSSX"     } as DateTime {         format : "yyyy-MM-dd HH:mm:ss"     } error while executing :  "reason": "DB:QUERY_EXECUTION", "message...

Mulesoft Certified Developer-Level2 - Study Material

Image
My Study Notes for Salesforce Certified Mulesoft Developer - Level2. Go thru chapter wise (DataSheet) reference links for each topic provided below and make notes for quick reference. Take Mulesoft Certified Developer Level2 Practice test provided by MuleSoft training as many times as possible @    https://training.mulesoft.com/certification/developer-mule4-level2/practice-exam   MCD Level2 - DataSheet Ch1:Expose production-ready Anypoint Platform managed APIs from Mule applications  https://help.mulesoft.com/s/question/0D52T00004mXYC6SAO/horizontal-scaling-vs-vertical-scaling-of-mule-workers Implement versioning of specific API-related artifacts https://docs.mulesoft.com/exchange/to-change-raml-version https://forum.raml.org/t/as-versions-is-managed-in-raml/788/3   Configure custom or out-of-the-box (OOTB) API policies https://docs.mulesoft.com/gateway/policies-included-http-caching https://docs.mulesoft.com/api-manager/1.x/json...