cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jheislerrad
Advocate I
Advocate I

Variable Keeps getting set to nul

So, basically:

I have an "AddMedia" control in a form. I then need to convert that picture to base64 to store in my Sharepoint list.

So far I've tried the following in the "OnSelect" field, but both just set the variables "ImageBinaryRaw" and "ImageBinary11" to null....

Set(
    ImageBinaryRaw,
    JSON(
        UploadedImage1.Image,
        IncludeBinaryData
    )
);
Set(
    ImageBinary11,
    Mid(
        ImageBinaryRaw,
        Find(
            ",",
            ImageBinaryRaw
        ) + 1,
        Len(ImageBinaryRaw) - Find(
            ",",
            ImageBinaryRaw
        ) - 1
    )
)

And:

Set(
    ImageBinaryRaw,
    JSON(
        UploadedImage1.Image,
        JSONFormat.IncludeBinaryData
    )
);
Set(
    ImageBinary11,
    Mid(
        ImageBinaryRaw,
        24,
        Len(ImageBinaryRaw) - 24
    )
)

 

9 REPLIES 9
StalinPonnusamy
Super User
Super User

Hi @jheislerrad 

 

I tried to convert and works fine.

 

StalinPonnusamy_0-1643062029880.png

 

Note: I was also getting empty initially and I changed the variable name and the screen. That fixed the issue.

 


Thanks,
Stalin - Learn To Illuminate

So, I tried setting the variable using "User().Image" and that worked. I guess I've got to do some troubleshooting with the add image control...

Hi @jheislerrad 

 

  • Try different image control with different variable name
  • Another option is to use the attachment control as well. This also should work. Please watch Shane's video which describes using attachment control itself.


Thanks,
Stalin - Learn To Illuminate

Thanks @StalinPonnusamy !

  • I tried a different Image control with no luck
  • Also tried different variable names, also no luck
  • Haven't tried the attachment control, but I may have too as I'm running out of options

The frustrating part is that I have the exact same setup working perfectly fine in another app...

jheislerrad
Advocate I
Advocate I

Okay this is interesting...

After some testing, I found the issue is only if the referenced control (UploadedImage1 in this case) or the button being pressed is in a data card on a form. If the control and button are in the root of a screen, it works fine.

 

I'm not sure why this would be though... Especially because it works fine in another app.... Is there like a setting or a data protection thing I'm missing?

I don't think so. Are you using Attachment control within the form which not working?

jheislerrad
Advocate I
Advocate I

its like the edit form cant interact with anything else in the app:

Here I have an image control selected. The image is set to "UploadedImage.Image" which is the Image from the "Add Media" control on the datacard within the form. The Selected image is not in the editform. As you can see the selected image is blank, while the image in the datacard is not...

jheislerrad_0-1643215741832.png

 

Hi @jheislerrad 

 

I don't we can reference an image from another image control. But we can convert the image to JSON and save it to a datasource.

jheislerrad
Advocate I
Advocate I

Hey All-

The issue I was having here was solved in this post:

Solved: Set function not working within datacard - Power Platform Community (microsoft.com)

Thanks!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (5,299)