Setting a Data Slot on Update of Datasheet

Hi, Is it possible to set a data slot automated to a value of a field in a datasheet when this updates? After a user logs into my app he/she gets redirected to a screen. I also set the User-ID to a data slot which then loads the user data into a datasheet. That works fine so far. On that screen I would like to use a data slot to set the state of the screen to show different screens to different types of users. So, I need to get a field value in the user record into a data slot to set the state based on this data slot. Is this possible?

Hey @Oliver_Burrell, I believe I can help you with but I am not sure you are working with Firebase. If you do, you would have to edit the plugin and it is not difficult to do because I could do it myself and I am the opposite to an expert here. But I could share the code so you can adapt it to your needs.

Thanks @petoma, I am working with Xano in this project.
I could change the plugin code for Xano as well but I thought there might be an easier way …

1 Like

I have not tested this idea, but it should work.

What you could do is take one of the user data fields (any one will do) and set a script interaction for it (when user updates text) and then in the script put:

var somevar = some logic here;
this.props.appActions.updateDataSlot('ds_state_you_want', somevar);
return input;

Like I said: I have not tested this, but in theory t should work fine

A

Hi @Adam_Wasserman, that’s about what I did this morning ;).
After the login it redirects to a screen and I wrote a state transformer script to get the mode out of the users record and set the state of the screen to show different content for different users. Works nicely :grinning:

// Search through the users datasheet (should only be one record in it anyway)
let dsArr =this.props.appActions.getDataSheet(“users”);
var arrayLength = dsArr.items.length;
for (var i = 0; i < arrayLength; i++) {
if (dsArr.items[i].id == this.props.appActions.dataSlots[‘ds_userId’]) {
this.props.appActions.updateDataSlot(‘ds_mode’, dsArr.items[i].last_mode);
input=dsArr.items[i].last_mode;
break;
}
}

return input;