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

Own Inspection app help

Hi,

 

I'm trying to build my own inspection app and I cannot find a solution for my idea.

 

I have a SharePoint list with Questions (the question are managed from that list if needed more or change):

TheSlawekG_0-1660921635800.png

A person who is responsible for inspections can go to the screen "Create new audit", select who will be the Audit for that audit and press Create button.

As you can see above, I have a list called "Audits".

TheSlawekG_1-1660921980195.png

After someone presses Create, a new entry should be added to this list (I know how to achieve this) but also I would like all questions to be copied to AuditsQuestions list with their Audit ID number.

TheSlawekG_2-1660922313857.png

 

How can I achieve this?

I am also open to other solutions.

 

Thank you.

Regards

 

Slawek

1 ACCEPTED SOLUTION

Accepted Solutions
Roverandom
Solution Supplier
Solution Supplier

When you go to create a new audit, do this:

/*
If you need to use this data through your app, use a global variable. Regardless of the variable, the result will be a record that the Patch function returns, containing the ID of the saved item.
*/
UpdateContext({
    varNewAudit:
        Patch(
            Audits,
            Defaults(Audits),
            {
                //...
            }
        )
});

ForAll(
    Questions,
    Patch(
        AuditsQuestions,
        Defaults(AuditsQuestions),
        {
            AuditID: varNewAudit.ID,
            Question: ThisRecord.Question,
            Section: ThisRecord.Section
        }
    )
)


Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.

View solution in original post

2 REPLIES 2
Roverandom
Solution Supplier
Solution Supplier

When you go to create a new audit, do this:

/*
If you need to use this data through your app, use a global variable. Regardless of the variable, the result will be a record that the Patch function returns, containing the ID of the saved item.
*/
UpdateContext({
    varNewAudit:
        Patch(
            Audits,
            Defaults(Audits),
            {
                //...
            }
        )
});

ForAll(
    Questions,
    Patch(
        AuditsQuestions,
        Defaults(AuditsQuestions),
        {
            AuditID: varNewAudit.ID,
            Question: ThisRecord.Question,
            Section: ThisRecord.Section
        }
    )
)


Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.
TheSlawekG
Helper II
Helper II

Hi @Roverandom 

 

thank you very much!

This is what  I needed and by this example, I learned something new.

 

Regards

Slawek

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,813)