I have a DataWeave script to remove all non-numeric characters from a phone number field. The code works correctly in the DataWeave Playground, but throws an error in Anypoint Studio. The payload is
{
"Recipient": {
"Name": "Bob Newhart",
"MailingAddress": {
"Line1": "123 Main Street",
"Line2": "Apt 5",
"City": "Cumming",
"State": "GA",
"ZipCode": "30009",
"ZipCodePlus4": "3382"
},
"PhoneNumber": "(999) 555-1234",
"Company": "Disney"
}
}
And the script is
%dw 2.0
output application/json
---
(
payload: payload update {case .Recipient.PhoneNumber -> replace (payload.Recipient.PhoneNumber, /\D/) with ""}
).payload
I am running this version of Anypoint Studio
Version: 7.4.2
Build Id: 202001311805
and the error message returned by Anypoint Studio is: Invalid input "update {case ", expected schema or & (line 6, column 20):
The update operator was added in Mule 4.3.0. If you are using an older Mule version it won't be available. Probably Studio 7.4.2 doesn't know about it either.