Hello everyone,
I have added an "Add picture" control to my form and I have a gallery displaying all the images being stored in a collection.
I have a text box, which I want the user to state the file name in, but as they have the option to add multiple images I want them to firstly be notified onscreen that the text box is empty, but also be notified if the text they have entered in the text box already exists in the collection - Some users with enter say test1 and upload multiple images under the same name, want to avoid this.
This is what I have so far on the OnChange property of my AddMediaButton1:
If(IsBlank('FileName-TxtInp'.Text), Notify("Enter a filename before proceeding", NotificationType.Error, 3000),
If(UploadedImage1.Image=SampleImage, "", Collect(ImageCollection, {Image:UploadedImage1.Image, FileName: 'FileName-TxtInp'.Text & "-" & DataCardValue39.Text //RefNumber field on the last screen
& ".jpg"})))
Thanks
Hi @Lefty ,
Something like this should do it
If(
IsBlank('FileName-TxtInp'.Text),
Notify("Enter a filename before proceeding", NotificationType.Error, 3000),
If(
!IsBlank(
LookUp(
ImageCollection,
FileName='FileName-TxtInp'.Text
).FileName,
Notify("Filename already exists", NotificationType.Error, 3000)
),
If(
UploadedImage1.Image=SampleImage, "",
Collect(
ImageCollection,
{
Image:UploadedImage1.Image,
FileName: 'FileName-TxtInp'.Text & "-" & DataCardValue39.Text & ".jpg"
}
)
)
)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @Lefty ,
Free-typing - bracket in the wrong place
If(
IsBlank('FileName-TxtInp'.Text),
Notify("Enter a filename before proceeding", NotificationType.Error, 3000),
If(
!IsBlank(
LookUp(
ImageCollection,
FileName='FileName-TxtInp'.Text
).FileName
),
Notify("Filename already exists", NotificationType.Error, 3000),
If(
UploadedImage1.Image=SampleImage, "",
Collect(
ImageCollection,
{
Image:UploadedImage1.Image,
FileName: 'FileName-TxtInp'.Text & "-" & DataCardValue39.Text & ".jpg"
}
)
)
)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Thanks no code errors
BUT its not working the way I need,
It still allows me to add "Test" as the file name, in the text input field, and I can add multiple images, with the same name "Test" this is pretty much what I don't want it to do:
I thought of another way, just reset the textinput box after the image is added to the collection, making the user re-type, of course, they may type the same name but at least its more obvious the user has done so
@Lefty ,
I am a bit surprised that does not work as it would be a better solution than hoping the user does not type in "test" again. This code
If(
!IsBlank(
LookUp(
ImageCollection,
FileName='FileName-TxtInp'.Text
).FileName
),
Notify("Filename already exists", NotificationType.Error, 3000),
. . . . . . .
is simply looking for a value in the FileName field of ImageCollection that is the same as the value the user typed in the 'FileName-TxtInp' Text box and giving a a warning (and stopping the save) if one is found.
What have I missed here?
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Is the issue because the collection is being created after?
Yes I agree it would be a better solution, but i'm unsure how to fix your suggestion, as that part of the code does not seem to check the collection for the name of the image, I have removed the refnumber field and only left the filename and .jpg to see if that was causing an issue, but allowed me to upload the same named files
@Lefty ,
Yes - if it was collected after the test, obviously that would not work.
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |