Help with simple coding function block

Question first
I am trying to pass the offset time from a funtion block I use to calculate it to a schedex node (as in https://flows.nodered.org/node/node-red-contrib-schedex) and am having isses trying to work out the format.
I have tried
Newmsg.payload.onoffset = -67;
return Newmsg

But thats throwing an error. Help please/

Additional info
I am a self taught Delphi/Pascal programmer. I am not used to such things as case sensitve variables etc so have learnt that fairly quick. I also use commercial PLC units and prefer to write code in them as appossed to simply using lines and blocks.
I like using Node-Red and am trying to get my head around function block programming and usually learn by trying. I know the above is a simply flaw on my behalf but need some info

Got it…

Its got to be done like json structure

newMsg.payload = {“onoffset”:tt}

It all depends on what google search terms you use :slight_smile:

Just a little information to help you in the future. Essentially your two examples are the same. I am assuming you declared Newmsg like const Newmsg = {}; or something equivalent. In the first example Newmsg.payload is undefined so you’re going to get an error when you try and create another object on top of it.

Here’s an example how your first example could possibly be valid.

const Newmsg = {};
Newmsg.payload = {};
Newmsg.payload.onoffset = -67;
return Newmsg;

or in one go

const Newmsg = { payload: { onoffset: -67 } };
return Newmsg;

Thank you.

Yes I originally thought payload was a part of newmsg so declaring newmsg meant payload was declared. That now makes a bit more sense…