Custom Concatenate

31 views
Skip to first unread message

Kayin Scholtz

unread,
Sep 4, 2017, 10:58:11 AM9/4/17
to OpenFn Community
Hi All,

I've looked over the custom concatenation help Open FN's documentation provides (see below), but I'm struggling to figure out how to concatenate three values together.

I have data coming in from an ODK form with birth-year, birth-month and day and I want to concatenate that into a value that can be understood by a Salesforce date field, which would look something like  birthyear/birthmonth/day.

Open FN's custom concatenate:
field("ODK_Key__c", function (state) {
          return (
            dataValue("metaId")(state).concat(
              "(", dataValue("index")(state), ")"
            )
          )
        })

Taylor Downs

unread,
Sep 4, 2017, 12:05:01 PM9/4/17
to Kayin Scholtz, OpenFn Community
Interesting! Once you build your date string (e.g., "1997-03-21") you'll need to call new Date("1997-03-21").toISOString() to get it into the required Salesforce format. See here: http://openfn.github.io/docs/documentation/#convert-date-string-to-standard-iso-date-for-salesforce

Using that with str.concat could look like this:

field("sf_date__c", function(state) {
  const string = dataValue("year")(state).concat(
    "-",
    dataValue("month")(state),
    "-",
    dataValue("day")(state)
  )
  return new Date(string).toISOString()
})

--
You received this message because you are subscribed to the Google Groups "OpenFn Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openfn+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openfn/6f6a8542-2ab2-41b0-9031-8ae88e23b1d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Taylor Downs | Founder & Core Contributor
OpenFn | Integrated Systems for Development

Kayin Scholtz

unread,
Oct 3, 2017, 9:16:01 AM10/3/17
to OpenFn Community
Thanks so much Taylor, very helpful!
To unsubscribe from this group and stop receiving emails from it, send an email to openfn+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages