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

Issues with adding and viewing images with "Add Picture" control

Hi all,

 

Adding images via "Add Picture" control and then viewing them in a gallery I am experiencing issues with:

  • Wrong images are displayed when in the edit screen

  • Images saved via mobile are only visible on the device that posted the image
    and the same goes if images are posted via Web interface on a computer

  • When editing a record as in adding an additional image it deletes the previous one
    and when saving the records it creates a new record instead of appending the images
    to the existing record

I am using a simple form that was built from scratch and only using Patch and Collect for data collecting and saving so

no Datacards, SubmitForms, etc are used. To keep things simple I am using separate Forms for new records and for editing records.

The attached files are showing the workflow for the Add new record and Edit record processes.




1 ACCEPTED SOLUTION

Accepted Solutions

Hi @DG1000 ,

Are the "TicketID" value and "ImageData" value stored within your new  added SQL Table properly?

Could you please show more details about the data within your new added SQL Table?

 

Please make sure that the OnSelect property of the ">" icon within your SQL Table records Gallery in GalleryScreen to following:

Set(CurrentItem, ThisItem);
Clear(MyCam);
ForAll(
       Filter('[dbo].[TicketsITImages]', TicketID = CurrentItem.ID),
       Collect(
               MyCam,
               {
                 ID: TicketID,
                 IMAGE: ImageData
               }
       )
);
Navigate(EditScreen)

the above ForAll function would be used to retrieve related image records from your new added SQL Table based on the current TicketID value. Please check if the MyCam collection has been populated with proper records when you press the ">" icon within your SQL Table records Gallery.

Within this SQL Table records Gallery, set the Image property of Image control to following:

Last(Filter('[dbo].[TicketsITImages]', TicketID = ThisItem.ID)).ImageData   // display the latest image related to current Ticket record

 

Within your Edit Record screen and New Record screen, set the Items property of Vertical Gallery to following:

MyCam

set the Image property of Image control in this Vertical Gallery to following:

ThisItem.IMAGE

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @DG1000 ,

Do you want to save image along with other fields data back to your SQL Table?

Do you use the collection to store the image for each record in your SQL Table?

 

Based on the screenshot and formulas you provided, I think there is something wrong with it. Firstly, if you want to store the images for each record in a collection, I afraid that there is no way to achieve your needs.

The collection is a temporary table data within canvas app, which would be destroyed when you close your canvas app. And you could save single one image data back to the IMAGE field in your SQL Table from your canvas app.

In addition, when you edit an existing record in your SQL Table, the standard format should be like below:

Patch(
       '[dbo].[SQLTable]',
       LookUp('[dbo].[SQLTable]', PrimaryKey = "xxxxx"),  // Find the record you want to update
       {
          CREATOR: txtCREATOR_1.Text,
          PRIORITY: cmbPRIORITY_1.Selected.Value,
          ...
          ...
       }
)

 

As an fixed solution, you could create another SQL table (called "[dbo].[TicketsITImages]") to store the images for each record in your current SQL Table ('[dbo].[tblTicketsIT]'). Within the '[dbo].[TicketsITImages]' table, you need to add the following columns:

TicketID int primary key not null,

ImageData varchar(max)

Note: The TicketID column is used to store the ID column value of the Ticket record in your '[dbo].[tblTicketsIT]' table.

 

Within your UploadImageNewScreen, set the OnSelect property of the "Upload" button to following:

Collect(
        MyCam,
        {
         IMAGE: UploadedImage2.Image
        }
)

 

Within your New Record Screen, set the OnSelect property of the "Save" button to following:

Set(
    CurrentItem,
    Patch(
          '[dbo].[tblTicketsIT]',
          Defaults('[dbo].[tblTicketsIT]'),
          {
            CREATOR: txtCREATOR_1.Text,
            PRIORITY: cmbPRIORITY_1.Selected.Value,
            DEPARTMENT: txtDEPARTMENT_1.Text,
            LOCATION: txtLocation_1.Text,
            ISSUE: txtISSUE_1.Text
          }
    )
);
ForAll(            // add formula here to upload image back to new added SQL Table for above submitted Ticket record
       MyCam,
       Patch(
              '[dbo].[TicketsITImages]',
              Defaults('[dbo].[TicketsITImages]'),
              {
                TicketID: CurrentItem.ID,
                ImageData: IMAGE                   // IMAGE column value is from MyCam collectino
              }
       )
);
Set(CurrentItem, Blank());
Reset(...);
....
Clear(MyCam);
Nvigate(GalleryScreen)

 

Within your GalleryScreen, set the OnSelect property of the ">" icon to following:

Set(CurrentItem, ThisItem);
Clear(MyCam);
ForAll(
       Filter('[dbo].[TicketsITImages]', TicketID = CurrentItem.ID),
       Collect(
               MyCam,
               {
                 ID: TicketID,
                 IMAGE: ImageData
               }
       )
);
Navigate(EditScreen)

 

Within your UploadedImageEditScreen, set the OnSelect property of the "Upload" button to following:

Collect(
        MyCam,
        {
          IMAGE:UploadedImage2_1.Image
        }
)

 

Within your Edit Record Screen, set the Items property of the Vertical Gallery to following:

 

MyCam

 

set the Image property of the Image control within this Vertical Gallery to following:

 

ThisItem.IMAGE

 

Set the OnSelect property of the "Save" button to following:

Patch(
       '[dbo].[tblTicketsIT]',
        LookUp('[dbo].[tblTicketsIT]', ID = CurrentItem.ID),  // Find the record you want to update
        {
            CREATOR: txtCREATOR_1.Text,
            PRIORITY: cmbPRIORITY_1.Selected.Value,
            DEPARTMENT: txtDEPARTMENT_1.Text,
            LOCATION: txtLocation_1.Text,
            ISSUE: txtISSUE_1.Text
        }
);
ForAll(
       Filter(MyCam, IsBlank(ID)),   // Find these new appending image data
       Patch(
             '[dbo].[TicketsITImages]',
              Defaults('[dbo].[TicketsITImages]'),
              {
                TicketID: CurrentItem.ID,
                ImageData: IMAGE                   // IMAGE column value is from MyCam collectino
              }
       )
);
Set(CurrentItem, Blank());
Reset(...);
...
...;
Clear(MyCam);
Navigate(GalleryScreen)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your reply,

 

I tried your suggested solution as you were correct in your assumption that I was trying to save a collection

into an IMAGE field in the same SQL table where all records are stored.

 

  • Created a new SQL table "TicketsITImages" with primary key and two columns "TicketID" and "ImageData"
  • Copied your suggested code

But after creating a couple of records still, no images are visible in the galleries...😕
then in edit mode, a noticed an error message that wasn't visible before(see attached image)

Update: after some other odd issues I decided to delete the table and creata a new one. That seems to have solved the issue with specified column... Now I can confirm that TicketID and ImageData are written to the table but still they are not visible in the gallery😑

to the table

 

Hi @DG1000 ,

Are the "TicketID" value and "ImageData" value stored within your new  added SQL Table properly?

Could you please show more details about the data within your new added SQL Table?

 

Please make sure that the OnSelect property of the ">" icon within your SQL Table records Gallery in GalleryScreen to following:

Set(CurrentItem, ThisItem);
Clear(MyCam);
ForAll(
       Filter('[dbo].[TicketsITImages]', TicketID = CurrentItem.ID),
       Collect(
               MyCam,
               {
                 ID: TicketID,
                 IMAGE: ImageData
               }
       )
);
Navigate(EditScreen)

the above ForAll function would be used to retrieve related image records from your new added SQL Table based on the current TicketID value. Please check if the MyCam collection has been populated with proper records when you press the ">" icon within your SQL Table records Gallery.

Within this SQL Table records Gallery, set the Image property of Image control to following:

Last(Filter('[dbo].[TicketsITImages]', TicketID = ThisItem.ID)).ImageData   // display the latest image related to current Ticket record

 

Within your Edit Record screen and New Record screen, set the Items property of Vertical Gallery to following:

MyCam

set the Image property of Image control in this Vertical Gallery to following:

ThisItem.IMAGE

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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 (64,204)