Convert month value (i.e. December) to numeric value (i.e. 12)

Thank you all in advance for assistance.

I am new Celigo user and need help converting a month (coming in from the source as string value (i.e. December, January, March, etc.)) to a numeric value that would correspond with that month (i.e. 12 , 1, 3) for import into the Destination app.

What is the best way to approach this?

H @daveguderian , In your mapping, you can click on the gear next to the destination field , and select "lookup", and then "static Value to Value". You will enter in the "export field value" your month , e.g :December and in the "import field value" the numeric value of the month, e.g: 12.Hope that helps.

https://docs.celigo.com/hc/en-us/articles/360019506771-Map-source-data-fields-to-destination#static


@daveguderian, alternatively, you can use a handlebar expression like below.

{{{dateFormat "M" month "MMMM"}}}

https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-helper-reference#dateFormat

https://docs.celigo.com/hc/en-us/articles/360045564992-Time-and-date-format-codes

Thank you both for the help. I sincerely appreciate it.

Will both of these methods work for mapping multiple months? For example, I have one flow built out, but will be receiving credit card payments from different customers which will have Jan-Dec expiration dates (for the month). It looks like using Youssef's method I am only able to map one month at a time and thus would need to create different imports for each month (so 12 different imports), but want to make sure what I am seeing is correct.

Thanks again!

@daveguderian, the single handlebar expression would take care of all of them. Here is an example of all 12 months and how the handlebar evaluated to the correct month digit.

For Youssef's method, it would be a single import step with a field setting of static to static value mapping like this.

This did the trick! Thank you so much.

Now I need to figure out how to combine the two digit year onto it, so for example a credit card that has an expiration of May 2026 will feed into salesforce as 0526. Would that require a whole new import since our field in salesforce is just one field (MMYY)?

@daveguderian it would be something like this. Assuming you have individual fields for year and month.

{{{join "" (dateFormat "MM" month "MMM") (dateFormat "YY" year "YYYY")}}}

Thanks so much for the help on this Tyler, I feel like I am getting close!

It is working perfectly in the playground, but when I insert the handlebars into the flow (copy and paste from playground) I am receiving the following error when trying to preview the data (appears to be the same error also when the flow runs). I tried to research the error and it appears to be something to do with the input, but I’m unclear on next steps.




David,

You only need the {{join .... }} statement as the mapping.

The first two lines was just Tyler giving you an example of what the dateFormat function would do to each statement individually.

Also, double check the field mapping. is ExpirationMonth and ExpirationYear the correct path to the value you want to pass into the function? if you look at the error record it will show you the exact JSON that was used. you may need to put record.ExpirationMonth and record.ExpirationYear

Kelly-

This worked and the data is posting correctly now. Thanks again for all of the help on this and your responsiveness.