我有一个名为'finalPrice'的全局函数,该函数在configuration.xml文件中定义。 该函数接受一个值-对其进行填充-并返回最终值。我从DataWeave中引用该函数。单击“预览”时,我可以在预览窗口中看到正确的输出。但是,当我运行它时,出现错误:
消息:执行时发生异常:
没有名为“ finalPrice”的变量。
我已经在本地计算机和CloudHub中运行了代码,并且得到了相同的结果
XML代码:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
DataWeave代码:
//Refer to "finalPrice" Global Function in the main.xml configuration file
DB_FINL_PRCE: "field_missing" when payload01.DB_FINL_PRCE == "" otherwise finalPrice(payload01.DB_FINL_PRCE)
任何帮助表示赞赏
答案 0 :(得分:2)
这是全局函数中的注释问题。因此,删除或修改该行:
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
只有:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
或将您的评论修改为//
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<global-functions>
//This function is called by the 'Validate and Transform' dataweave component in the 'main' flow
def finalPrice(incoming_value)
{
// Do Stuff
return "somethingelse";
}
</global-functions>
</expression-language>
</configuration>