Transform connector fails in the Anypoint CloudHub

153 views Asked by At

I have a transform action which has the logic like below

%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
   "quoteId" : vars.setQuoteOppRecIds.Id,
   "productCode" : payload.ServiceTypeCode,
   "axSequenceNumber" : vars.counter as Number,
   "phaseLevel" : payload.PhaseLevel as Number,
   "phaseLevelDescription": payload.PhaseLevelDescription,
   "projectWeekStart" : payload.PhaseLevelProjectWeekStart as Number,
   "projectWeekEnd" : payload.PhaseLevelProjectWeekEnd as Number,
   "quantity": payload.Quantity as Number,
   "invoicedSinceLast" : payload.InvoicedSinceLast as Number, 
   "unitPrice": (payload.UnitPrice replace "," with "") as Number {format: ".00"} as String {format: ".00"} as Number,
   "oppId" :  if (isEmpty(vars.inputPayload.Opportunity.OpportunityId)) (vars.oppID) else (vars.inputPayload.Opportunity.OpportunityId) 
}

When debugging this transform locally it works without any issues but after deploying to CloudHub it throws error like

Unable to resolve module with identifier dw::util::Coercions. at 2 : 2
    at org.mule.weave.v2.el.WeaveExpressionLanguage.compile(WeaveExpressionLanguage.scala:68)
    at org.mule.runtime.core.internal.el.dataweave.DataWeaveExpressionLanguageAdaptor.compile(DataWeaveExpressionLanguageAdaptor.java:143)
    at org.mule.runtime.core.internal.el.DefaultExpressionManager.compile(DefaultExpressionManager.java:233

I am new to mulesoft I didnt capture this error when debugging locally but why does it throws when running the API in the CloudHub

1

There are 1 answers

0
aled On BEST ANSWER

The DataWeave package dw::util::Coercions used in the script was added to Mule since Mule 4.4.0. You are probably deploying in CloudHub to an earlier version of Mule that doesn't support it. Re deploy the application to Mule 4.4.0 and it should work.

Alternatively, since your script doesn't use any of the functions provided by that package you could just delete the import line.