cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Microsoft
Microsoft

Re: Displaying image using 64base

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

 

Highlighted
Post Prodigy
Post Prodigy

Re: Displaying image using 64base

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?

Highlighted
Microsoft
Microsoft

Re: Displaying image using 64base

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

Highlighted
Post Prodigy
Post Prodigy

Re: Displaying image using 64base

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

Highlighted
Microsoft
Microsoft

Re: Displaying image using 64base

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

Highlighted
Post Prodigy
Post Prodigy

Re: Displaying image using 64base

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? 

Highlighted
Microsoft
Microsoft

Re: Displaying image using 64base

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

Highlighted
Post Prodigy
Post Prodigy

Re: Displaying image using 64base

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

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

Highlighted
Post Prodigy
Post Prodigy

Re: Displaying image using 64base

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

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,585)