cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Displaying image using 64base

Hello!

I have a ticket system application where they can add a picture. This picture gets saved to my SharePoint list using this code: 

Patch(
       'Foto''s Manco App',
       Defaults('Foto''s Manco App'),
       {Title: DataCardValue12.Text & " " & DataCardValue24.Text,
         ImageData: Substitute(JSON(UploadedImage1.Image,JSONFormat.IncludeBinaryData),"""","")
       }
)

 It looks like this: https://gyazo.com/5c8b7dcb733b60d00e54b47038f592c2

I use: "AddMediaButton1.Media" to get the picture into the "UploadedImage1"

I then made a formula that would display the image but this does not seem to work anymore. 

LookUp('Foto''s Manco App', Title= DataCardValue12.Text & " " & DataCardValue24.Text, ImageData)

I used this formula instead of "AddMediaButton1.Media", this code would check if there is a picture in the database, if there is not, get the picture using "AddMediaButton1.Media"

Code: 

If(LookUp('Foto''s Manco App', Title= DataCardValue12.Text & " " & DataCardValue24.Text, ImageData)= "", AddMediaButton1.Media, LookUp('Foto''s Manco App', Title= DataCardValue12.Text & " " & DataCardValue24.Text, ImageData))

 

How could I do this?

 

30 REPLIES 30
Community Support
Community Support

Hi @TimoMigchielsen :

Please try this code:

UploadedImage1.Image:

 

If(IsBlank(AddMediaButton1.Media),If(IsBlank(ThisItem.ImageData),SampleImage,ThisItem.ImageData), AddMediaButton1.Media)

 

AddMediaButton1.Text:

 

If(IsBlank(ThisItem.ImageData),"Tap or click to add a picture","Tap or click to change the picture")

 

5.gif

If your issue is resolved, please mark a valid response as solution,thank you.

Best Regards,

Bof

 

Instead of SampleImage I have used my LookUp formula, this has worked. However, when I edit a ticket and want to change the image, this does not work. Do you know why? @v-bofeng-msft 

 

I have to change another field, when that happends, it will change the picture too, how come?

Hi @TimoMigchielsen :

This problem is caused by logic error,you need to first determine whether there is a value in AddMediaButton1.Media.

 

If(IsBlank(AddMediaButton1.Media),If(LookUp('Foto''s Manco App', Title= DataCardValue12.Text & " " & DataCardValue24.Text, ImageData)= "", AddMediaButton1.Media, LookUp('Foto''s Manco App', Title= DataCardValue12.Text & " " & DataCardValue24.Text, ImageData)),AddMediaButton1.Media)

 

Best Regards,

Bof

I have tried it, it does change the picture but whenever I save it, I think it does not delete the old one and simply puts a new one in there, but it takes the first picture first in the list @v-bofeng-msft 

Edit:

yes, this is indeed what is happening. Proof: https://gyazo.com/fe2cfa2dea17d60054969731a7d3f3be

So somehow we need to delete a picture if there already was one on the onsuccess of the form? The Title column is based off this: 

Bestandsnaam space ticket id

Maybe we could use the auto ID that comes with every row? We could say always take the last ID of that Title

Hi @TimoMigchielsen :

Because the function of the path ()XX formula you use is to add a new record.

You need to adjust your code according to different needs,If you need to modify the record, please try this following code:

 

Patch(
       'Foto''s Manco App',
       ThisItem,
       {Title: DataCardValue12.Text & " " & DataCardValue24.Text,
         ImageData: Substitute(JSON(UploadedImage1.Image,JSONFormat.IncludeBinaryData),"""","")
       }
)

 

since your control is already in a form,I suggest you consider using the submitfrom function.

just set the imagedata datacards's update propery to:

 

Substitute(JSON(UploadedImage1.Image,JSONFormat.IncludeBinaryData),"""","")

 

 Best Regards,

Bof

I get an error using this code instead of the code I used, is it not possible to let it show the image with the highest ID?:

 

 

Patch(
       'Foto''s Manco App',
       ThisItem,
       {Title: DataCardValue12.Text & " " & DataCardValue24.Text,
         ImageData: Substitute(JSON(UploadedImage1.Image,JSONFormat.IncludeBinaryData),"""","")
       }
)

 

 

Error: https://gyazo.com/91fe4be9a4bcd3c4e84bd82c838831cf

Getting this error trying your second code: https://gyazo.com/680532528dddcf33272d9c8dac2dc255

So we could edit the LookUp formula to always look for the highest ID? 

Hi @TimoMigchielsen :

Yes.

Please try:

Patch(
       'Foto''s Manco App',
       First(Sort('Foto''s Manco App',ID,Descending)),
       {Title: DataCardValue12.Text & " " & DataCardValue24.Text,
         ImageData: Substitute(JSON(UploadedImage1.Image,JSONFormat.IncludeBinaryData),"""","")
       }
)

Best Regards,

Bof

Worked once, doesn't work anymore. @v-bofeng-msft 

We might still need to change the LookUp formula to show the latest picture 

What could I change the LookUp formula to? @v-bofeng-msft 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (69,888)