Pass value from custom component to temporary state variable

Probably overlooking something simple, but haven't been able to work it out yet via the docs or searching this forum.

I've created a custom component using FullCalendar to expand on the possibilities of the calendar component in Retool.

I'm looking to pass the week number of the visible week in the calendar back to a temporary state variable in retool. The week number of the current view can be called using getDate() from within the component.

My iframe code looks like this:

<script src=""></script>
<script src=""></script>

<link rel="stylesheet" href="">
<link href='' rel='stylesheet'>
<link href='' rel='stylesheet'>

window.Retool.subscribe(function(model, modelUpdate ) {
    if (!model) { return }
     var calendarEl = document.getElementById('react');
     var calendar = new FullCalendar.Calendar(calendarEl, {
       initialView: 'timeGridWeek',
       events: model,

       datesSet: function(info) {

<div id="react"></div>

With the code above, the console logs work as intended, so when I change to a different week the correct week is printed to the console (e.g. 45). I'm looking to pass this value to a temporary state in retool which I've called selected_week_num.

Can anyone point me in the right direction? :pray:

Here is how I do that:

  1. Have a JS query that sets the temp var.


  1. Update the model with the value you are passing
  2. Trigger the query from the Custom Component.



Thanks a lot @bradlymathews ! I'll take the time to go through this and try and get it working.

I was hoping I didn't have to change the model itself and write the value directly to the temporary state (maybe via a query), as the model I have is an object that I've transformed into an array to get the calendar title and time etc, as show here:

Ahh, I see.

My first guess in that case is to make you model something like this:

   calendar: {{formDataAsArray(import_agent... etc. ,
   properties: {
     week: 0

In your CC change events: model to events: model.calendar.

Then change your model like this:

window.Retool.modelUpdate({ properties: {week: moment(calendar.getDate()).isoWeek()}})

I am also very curious if anyone else comes up with a better pattern that I am using here.

Oh, one other comment about

I was hoping I didn't have to change the model itself and write the value directly to the temporary state (maybe via a query),

You can just run the query, but there is no way to pass a parameter back with that query like you normally can using additionalScope. I have a feature request for exactly that which will simplify things quit a bit. Please heart it and +1 it to get it some more traction!

Yup I think that's the way to go for my case! Thanks :pray: