Hi all,
Adding images via "Add Picture" control and then viewing them in a gallery I am experiencing issues with:
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.
Solved! Go to Solution.
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,
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,
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.
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,
User | Count |
---|---|
221 | |
99 | |
94 | |
55 | |
36 |
User | Count |
---|---|
273 | |
105 | |
104 | |
60 | |
60 |