Setting an image's value with a workflow

Seems like this should be simple. What am I missing?

I’m trying to set the image’s value to a pre-saved element’s value. Doesn’t seem to be working. Is there any way to set image to an element’s value when the thing is created? (see screenshot)

Hey @djtechwise :wave:

Hmm :thinking: Good question.

What about adding a default directly into the database instead? Either way should work.

Your workflow doesn’t work because it is expecting one type of value but not getting that type. What does the error tell you? Let me know. :blush: Hope to help figure this out for you.

Thanks for chiming in J805. Being new to the bubble way is difficult for me, I need all the help I can get.

The error message said something about expecting an image but instead this is an element.

Adding a default entry from the database won’t achieve my goal because I want to create 14 records that each have a different (default or starting) image.

Here’s what I am trying to do. (still in test mode)
I have loaded 18 images on a popup on the login page (hidden). Each image stores a different photo of a golf club. When a user creates an account, I’m using a workflow to create 18 records in the clubs table that have a reference to the current user (already logged in when the workflow starts) I’m having trouble setting the value of the field “clubimage” to the preloaded hidden image. I have a reference to the hidden image but I can’t set the field to that images’ value.

Is there a way to set the value of an image field to an image element while creating a new thing?

Should I be using “Make changes to a thing” instead?

Should I abandon the concept of using preloaded images in this way?

I’m stuck, please help if you can. -DJ

Hey @djtechwise :wave:

You can do it this way if you want, you just need to make sure you reference the actual image of what you are choosing. What happens when you click (More…) what does it show?

Also, if you are going to create 18 records for each user, maybe you can create templates in the database, then copy the templates for each user. Would that be a better option? There might be other options too, I just don’t know your full project in detail. :blush:

I typically use template records in the database when I need to create a bunch of items easily.

Does that make sense? Hope that helps a bit. :blush:

When the (More…) is clicked, it seems to wanting a state. Problem is, I have the exact same problem trying to set a state to the image’s value.

The template idea is interesting. How do you deal with the whole going live conversion? Don’t those records get deleted as test data?

Can you share a screenshot of the More… option?

For the template, you would also have to create templates in the live database as well. Otherwise, it won’t work in live. :blush: You can copy database records from test to live if there are a lot of records to copy.

Sorry, I meant to attach this screenshot

Working through this, I tried this:
In the same workflow, before the “create a new thing” step, I used
“set state” and “create a custom state” on the image element named “CI_Driver” I’m not able to set the value of the “CI_Driver” state to the value of the image element but I notice that the custom state is persistent and when I view it from element (on the ? icon on the top of the inspector window) I can manually upload what ever image I want effectively setting the state’s value to that image. I adjusted the workflow to set the value of of the club image field to that state and it worked.

My concern is, I don’t know if the state will remain persistent like that after the live conversion. I just don’t have enough experience with how the states work. In the testing mode, I seems the states remain accessible once they are created, they seem to remain available. Even after logging out and back in test mode. Since they are accessible I can just manually upload the desired image to the state.
So now my question is: Once a state is created, will remain as a permanent resource to store and reference these images? Seems contradictory to the nature of a variable and I’m thinking they only remain accessible because I’m in test mode.

Hmm :thinking:

Well, states are available on the page. If it works in test, then it should work in live too. It seems that there might be a bug accessing the state, or you might not be looking in the right place. So you put a default value right into the state?

To access the state, make sure to reference ‘CI_Drive’ then look for its state there. Right now you are accessing ‘ImageDef3W’ which doesn’t seem to have a state attached to it.

Each element on the page can have a state attached to it. I try to keep all of my states in one place if possible so it’s easy to remember how to access them.

Does that help at all? Let me know. :blush:

Ok, let me ask this way; if I create a custom state and manually upload an image to it, IS IT THERE FROM THAT TIME FORWARD AND FOREVER so that state can be used to populate the club image field every time a new user gets set up?

If can reliably store my images as states, I can just use this process to define which image is used for creating new records for each new user instead of storing them as image elements.

This seems crazy that It’s so difficult to create records and populate an image field with and image element’s value.

Yes, you can store a value like an image in a state and it will be available to you for as long as you have it there. :blush:

Nice. What happens when converting to live mode. Do these states have to be recreated then?

Nope, the states are the same. :blush: Only the database would be different if you used a database to create them.

Great. Just one more follow up on this. Check my thinking here; I plan to set up these default starting images to be stored as states. (instead of image elements) At some point in the future if I want to change the image stored in the states, I can just re-upload the new image to each state. From that point forward, any records created using these states will then used the new image but all the previously created records will still be have the old image stored in the field. Right?

Yes, as long as you set it up that way, that is correct. :blush:

Cool. Thanks for helping me through that. It’s all part of the learning curve for me.

1 Like

Yup, no worries. We were all there once. :blush: Glad to help!