Hi, I’m a newbie learning OpenFn, so probably my question is so elemental that I couldn’t found any answer at all. My problem is related with conditionals, so I write it here.
I already successfuly sent an email (with mailgun API) when a kobo submission arrives to OpenFn endpoint.
But now I want to send it to different emails according to a field value on kobo submission. So, I began to put this on the Job’s expression:
const f = state.data.f;
console.log("form name: " + f);
But get this error: “ReferenceError [Error]: f is not defined”; the error does not exists at all when console.log("form name: " + state.data.f);
Obviously, my idea was to continue with something like
if (f==“a”) then mailAddress = “email@example.com”;
and later on to use that mailAddress inside the send() function, if possible.
Clearly, I do not understand how the whole think works here.
My solution was to use different Triggers (filtering that “f” on the submitted forms from kobo) but does not seems as an “elegant” solution, specially if we have a lot of different kobotoolbox forms.
I will appreciate any advise. Thanks in advance.