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

I change the Image like this, this is indeed a form: https://gyazo.com/35310d76c073a6a405b6c9c282850069

I patch the Image like this using the send button of my form. 

 

 

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

 

 


How I look up the image on the detail screen:
https://gyazo.com/bf2c342e1d921ea575dd7b5c493605a3

How the add screen looks like:
https://gyazo.com/52a506bf5f0f9cfb3c72edd895f12476

How it gets written to the database:
https://gyazo.com/3160bf9a94987d34a3c2ca01cff2c073

As you can see, if someone changes the image, it will have the same name but a higher ID 

Code of UploadedImage1:

 

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)

 


Code of AddMediaButton1:

 

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

 


Item code of the EditForm:

SelectedItem

(Because I have multiple galleries)


@v-bofeng-msft 

Hi @TimoMigchielsen :

Back to the problem we discussed at the beginning:

I executed this code multiple times and it all works fine.

 

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),"""","")
       }
)

 

I can't figure out why it can only be executed once in your app, do you have any idea?

 8.gif1.JPG

Best Regards,

Bof

Now it does not work at all @v-bofeng-msft

It changes the picture on the detailscreen and shows the right picture. But as soon as I save it, it's saved to the database. Because it has the same name, it will always take the highest picture (So the first one they entered)
Because I use this code, so I am guessing we need to change this code: 

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


https://gyazo.com/480af5c182b6b6ce28179a9b9ee68489

Full code of the button, the code under the Patch code is to check if all fields that are required to be filled in, are filled in. If not, it will show a popup: 

 

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),"""","")
       }
);


If(!IsBlank(DataCardValue26.Text),
If(
    !IsBlank(DataCardValue22.Text)&&
    !IsBlank(DataCardValue21.Text)&&
    !IsBlank(DataCardValue9.Text)&&
    Or(DataCardValue18.Selected.Value <> "-",DataCardValue13.Selected.Value <> "-") &&
    !IsBlank(UploadedImage1.Image)&&
    !IsBlank(DataCardValue11.Text),
    If(
    CountRows(
        Filter(
            'Manco-Informatie',
            Value('Ticket ID') = Value(DataCardValue24.Text)
        )
    ) > 0,
    SubmitForm(EditForm);
    Navigate(
        Overzicht,
        None
    ),
    SubmitForm(EditForm)
    )
);

If(IsBlank(DataCardValue21.Text), UpdateContext({VarErrorOrder:true}),UpdateContext({VarErrorOrder:false})) ;
If(IsBlank(DataCardValue11.Text), UpdateContext({VarErrorDeelorder:true}),UpdateContext({VarErrorDeelorder:false}));
If(IsBlank(DataCardValue22.Text), UpdateContext({VarErrorTekening:true}),UpdateContext({VarErrorTekening:false}));
If(IsBlank(DataCardValue9.Text),  UpdateContext({VarErrorAantal:true}),UpdateContext({VarErrorAantal:false}));
If(IsBlank(AddMediaButton1.Media),  UpdateContext({VarErrorFoto:true}),UpdateContext({VarErrorFoto:false}));

If(
  DataCardValue18.Selected.Value = "-" &&
  DataCardValue13.Selected.Value = "-",
  UpdateContext({VarErrorInternExtern:true}),UpdateContext({VarErrorInternExtern:false})
), UpdateContext({Popup2:true}))



 

 

Hi @TimoMigchielsen :

I think this should have nothing to do with the code below.

Could you tell me whether the application displays any errors?

Best Regards,

Bof

No errors at all @v-bofeng-msft 

Why do you think it has nothing to do with the LookUp formula? That is the formula that gets the picture. Are you able to make a formula that looks up this: 

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

And then takes the highest ID, and then show ImageData? I think that will fix it 

Hi @TimoMigchielsen :

If you want to use lookup, the formula should be written like this

 

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

 

I did a test for this and it worked well.

Best Regards,

Bof

 

I changed the Patch code to that but I still do not get the other picture. @v-bofeng-msft  

 

Keep in mind that I am talking about 2 different Image controls, 1 on the detail page and 1 on the add screen.

Changed the LookUp formula to this and now it works I think:

Now on the detail screen it gets changed to the new Picture, but on the add screen, it is still the old picture

 

 

 

LookUp(Sort('Foto''s Manco App',ID,Descending),Title= DataCardValue16.Text & " " & DataCardValue19.Text, ImageData)

 

 



We now need to adjust this code of the UploadedImage of my add screen, I think we need to use the same formula somehow:

 

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)

 


Changed it to this code, it now fully works, thank you for your time!

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




-

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 (32,042)