cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meeh
Frequent Visitor

Patch value from dropdown in collection

I have canvas that submit into 2 lists - master & content. I have a button on the previous screen with OnSelect:

 

NewForm(Form1); ClearCollect(ContentCollection, {Doc_Code: "", Doc_Name: "", Type_of_Doc: ""});Navigate(CreateDAR,ScreenTransition.Cover)

 

 

The button navigates to the screen below.

dar.jpg

Master list is at the top. Content list is collection at the bottom. Master list has this OnSucess:

 

ForAll(ContentCollection,Patch(DAR_Content_DB,Defaults(DAR_Content_DB),
        {
            Doc_Code: Doc_Code,
            Doc_Name: Doc_Name,
            Type_of_Doc:Drop_Type_of_Doc
        }
    )
)

 

Doc_Code and Doc_Name is from Master list; Type_of_Dropdown is from Content list.

 

In Content list I have a drop-down with 3 choice. The Save butt has this OnSelect:

 

Patch(
    ContentCollection,
    ThisItem,
    {
        Doc_Code: InputDoc_Code.Text,
        Doc_Name: InputDoc_Name.Text,
        Type_of_Doc : Drop_Type_of_Doc.SelectedText.Value
    }
);
Collect(
    ContentCollection,
    {
        Doc_Code: "",
        Doc_Name: "",
        Type_of_Doc: ""
    }
);

 

 

The Next button has:

 

SubmitForm(Form1); Navigate(CompleteDAR, ScreenTransition.CoverRight)

 

 

The problems are:

 

dar2.jpg

 

1. The values from drop-down do not patch properly. It patches only the first choice from the first record. See above image, where it said Form, this is right but the second one should be Handbook as selected (see the first image).

2. Once submit, I always get an empty an record at the end (see image above). This is not a big deal tho, I can use Flow to clean it out by "on created items".

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Eelman
Community Champion
Community Champion

@Meeh 

Change your OnSuccess to this to remove the extra blank record:

ForAll(
    Filter(ContentCollection,!IsBlank(Doc_Code)),Patch(DAR_Content_DB,Defaults(DAR_Content_DB),
        {
            Doc_Code: Doc_Code,
            Doc_Name: Doc_Name,
            Type_of_Doc:Drop_Type_of_Doc
        }
    )
)

 

The reason why your dropdowns aren't correct is because you are using 'ThisItem'. ThisItem refers to the collection and you need to be referring to the Gallery. Something like this may work:

Patch(
    ContentCollection,
    Gallery1.Selected,
    {
        Doc_Code: InputDoc_Code.Text,
        Doc_Name: InputDoc_Name.Text,
        Type_of_Doc : Drop_Type_of_Doc.SelectedText.Value
    }
);

Change 'Gallery1' to your gallery name. I'm not 100% sure of how to reference the Gallery item (not ThisItem) so you may need to play around with to get it to work?

 

 

View solution in original post

2 REPLIES 2
Eelman
Community Champion
Community Champion

@Meeh 

Change your OnSuccess to this to remove the extra blank record:

ForAll(
    Filter(ContentCollection,!IsBlank(Doc_Code)),Patch(DAR_Content_DB,Defaults(DAR_Content_DB),
        {
            Doc_Code: Doc_Code,
            Doc_Name: Doc_Name,
            Type_of_Doc:Drop_Type_of_Doc
        }
    )
)

 

The reason why your dropdowns aren't correct is because you are using 'ThisItem'. ThisItem refers to the collection and you need to be referring to the Gallery. Something like this may work:

Patch(
    ContentCollection,
    Gallery1.Selected,
    {
        Doc_Code: InputDoc_Code.Text,
        Doc_Name: InputDoc_Name.Text,
        Type_of_Doc : Drop_Type_of_Doc.SelectedText.Value
    }
);

Change 'Gallery1' to your gallery name. I'm not 100% sure of how to reference the Gallery item (not ThisItem) so you may need to play around with to get it to work?

 

 

Meeh
Frequent Visitor

Thank you! Your solutions worked!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,831)