After messing around with this for a while i realized the function that makes MakeDataMatrixBarcode work is located in Builtins.js.
So i copied the code for that and replaced the variables with my values and it works now. Here is the code for reference:
function DataMatrixBarcode(ProcessTilde, EncodingMode, PreferredFormat, PointSize, NoFontTag, Font)
{
this.processTilde = true;
this.encodingMode = "TEXT";
this.preferredFormat = 2;
this.pointSize = 3;
this.noFontTag = false;
this.font = "IDAutomationDMatrix";
}
//__________________________________________________________________
DataMatrixBarcode.prototype.Encode = function(DataToEncode)
{
return EncodeDataMatrixBarcode(Field("Match"), this.processTilde, this.encodingMode, this.preferredFormat);
}
DataMatrixBarcode.prototype.Make = function(DataToEncode)
{
var encoded = this.Encode(Field("Match"), this.processTilde, this.encodingMode, this.preferredFormat);
var ReplacedBR = ReplaceSubstring(encoded, "\r\n", "<br>");
var ReplacedSpaces = ReplaceSubstring(ReplacedBR, " ", "");
if (!Int(this.pointSize))
return ReplacedSpaces;
var WithPointSize = "<z newsize=\"" + Int(this.pointSize) + "\">" + "<leading newsize=\"" + Int(this.pointSize) * 10 + "\">" + ReplacedSpaces;
if (this.noFontTag)
return WithPointSize;
var WithFontTag = "<f name=\"" + this.font + "\">" + WithPointSize;
return WithFontTag;
}
function datamatrix(DataToEncode, ProcessTilde, EncodingMode, PreferredFormat, PointSize, NoFontTag, Font)
{
return new DataMatrixBarcode(ProcessTilde, EncodingMode, PreferredFormat, PointSize, NoFontTag, Font).Make(DataToEncode);
}