- What comes out from the Debug: D2441
- What's Inside the Function:
- What i want to Happen:
I want the Value from the READ node to replace a msg.payload field in the Message To Cajo Function as it comes straight from DataBase as NULL as of now but our Customer wants that to be replaced with Date information from PLC.
I'm the worst at explaining but to simplify:
I want the DATE payload (as seen in the Node Text Below)to be changed to the payload sent from the PLC Tag
Message To Cajo Node looks like this Now:
var ART_BRAND = { payload: msg.payload[0].art_brand};
var ART_NR = { payload: msg.payload[0].art_nr};
var CUSTOMER_NR = { payload: msg.payload[0].customer_nr};
var LASER_MARKING_FILE = { payload: msg.payload[0].laser_marking_file };
var PRINT = { payload: msg.payload[0].print};
var DESCRIPTION = { payload: msg.payload[0].description};
var SAFETY_SYMBOL_TEXT = { payload: msg.payload[0].safety_symbol_text_field1};
var SAFETY_SYMBOL = { payload: msg.payload[0].safety_symbol_text_field2};
var FLEX_SYMBOL = { payload: msg.payload[0].flex_symbol_field3};
var SERIAL_NUMBER = { payload: msg.payload[0].flex_symbol_field4};
var PRODUCT = { payload: msg.payload[0].product_field5};
var TEXT_FIELD6 = { payload: msg.payload[0].text_field6};
var TEXT_FIELD7 = { payload: msg.payload[0].text_field7};
var TEXT_FIELD8 = { payload: msg.payload[0].text_field8};
var TEXT_FIELD9 = { payload: msg.payload[0].text_field9};
var TEXT_FIELD10 = { payload: msg.payload[0].text_field10};
var TEXT_FIELD11 = { payload: msg.payload[0].text_field11};
var CHARGE = { payload: msg.payload[0].charge_field12};
var DATE = { payload:msg.payload[0].date_field13};
var SWEDEN = { payload: msg.payload[0].sweden_field14};
var BRAND = { payload: msg.payload[0].brand_field15};
var STROMS = { payload: msg.payload[0].stroms_field16};
var TRANAS = { payload: msg.payload[0].tranas_field17};
var PED_SYMBOL = { payload: msg.payload[0].ped_symbol_field18};
var CE_SYMBOL = { payload: msg.payload[0].ce_symbol_field19};
var FIFTEENKG_SYMBOL = { payload: msg.payload[0]["15kg_symbol_field20"]};
//var TEXT_FIELD9Mod = { payload: msg.payload[0].text_field9Mod};
var SerialNumberOutput = global.get("SerialNumberOuput");
//var DATE = global.get("DateTest") ;
if (SAFETY_SYMBOL_TEXT.payload === null) {
SAFETY_SYMBOL_TEXT.payload = '';
}
if (SAFETY_SYMBOL.payload === null) {
SAFETY_SYMBOL.payload = '';
}
if (FLEX_SYMBOL.payload === null) {
FLEX_SYMBOL.payload = '';
}
if (SERIAL_NUMBER.payload === null) {
SERIAL_NUMBER.payload = '';
}
if (PRODUCT.payload === null) {
PRODUCT.payload = '';
}
if (TEXT_FIELD6.payload === null) {
TEXT_FIELD6.payload = '';
}
if (TEXT_FIELD7.payload === null) {
TEXT_FIELD7.payload = '';
}
if (TEXT_FIELD8.payload === null) {
TEXT_FIELD8.payload = '';
}
if (TEXT_FIELD9.payload === null) {
TEXT_FIELD9.payload = '';
}
if (TEXT_FIELD10.payload === null) {
TEXT_FIELD10.payload = '';
}
if (TEXT_FIELD11.payload === null) {
TEXT_FIELD11.payload = '';
}
if (CHARGE.payload === null) {
CHARGE.payload = '';
}
if (DATE.payload === null) {
DATE.payload = 'Test';
}
if (SWEDEN.payload === null) {
SWEDEN.payload = '';
}
if (STROMS.payload === null) {
STROMS.payload = '';
}
if (TRANAS.payload === null) {
TRANAS.payload = '';
}
if (PED_SYMBOL.payload === null) {
PED_SYMBOL.payload = '';
}
if (CE_SYMBOL.payload === null) {
CE_SYMBOL.payload = '';
}
if (FIFTEENKG_SYMBOL.payload === null) {
FIFTEENKG_SYMBOL.payload = '';
}
var templateId = '{"SetMarkingContent":{"TemplateId":"';
var templateId1 = '","Variables":[';
//var field1 = '{"Name":"Field1","Value":""},';
//var text2 = "World";
var fullmsg;
fullmsg = templateId.concat(LASER_MARKING_FILE.payload, templateId1, '{"Name":"Field1","Value":"', SAFETY_SYMBOL_TEXT.payload, '"},', '{"Name":"Field2","Value":"', SAFETY_SYMBOL.payload, '"},', '{"Name":"Field3","Value":"', FLEX_SYMBOL.payload, '"},', '{"Name":"Field41","Value":"', SerialNumberOutput, '"},', '{"Name":"Field42","Value":"', SerialNumberOutput, '"},', '{"Name":"Field43","Value":"', SerialNumberOutput,'"},','{"Name":"Field5","Value":"',PRODUCT.payload,'"},','{"Name":"Field6","Value":"',TEXT_FIELD6.payload,'"},','{"Name":"Field7","Value":"', TEXT_FIELD7.payload,'"},','{"Name":"Field8","Value":"', TEXT_FIELD8.payload,'"},','{"Name":"Field9","Value":"', TEXT_FIELD9.payload,'"},','{"Name":"Field10","Value":"', TEXT_FIELD10.payload,'"},','{"Name":"Field11","Value":"', TEXT_FIELD11.payload,'"},','{"Name":"Field12","Value":"', CHARGE.payload,'"},','{"Name":"Field13","Value":"',DATE.payload,'"},','{"Name":"Field14","Value":"', SWEDEN.payload,'"},','{"Name":"Field15","Value":"', BRAND.payload,'"},','{"Name":"Field16","Value":"', STROMS.payload,'"},','{"Name":"Field17","Value":"',TRANAS.payload,'"},','{"Name":"Field18","Value":"', PED_SYMBOL.payload,'"},','{"Name":"Field19","Value":"', CE_SYMBOL.payload,'"},','{"Name":"Field20","Value":"', FIFTEENKG_SYMBOL.payload,'"}]}}<EOT>');
msg.payload = fullmsg;