web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Audit App

(0) ShareShare
ReportReport
Posted on by 308

Hi 

 

I'm trying to make an audit app based into a model. The model is based on sql, I addapted to sharepoint list, that's ok. But the model has only two question, I need to addapt to serveral questions (same questions to all users).
The SubmitYesButton has now the code bellow and as you can see is saving each question a time, I need to addapt to consider several questions the most easy way instead of creating a patch for each one, could you help me?

Regards

 

 

/*This is the beginning of the Patch fuction*/
/* This section has to remain on the top since it saves the Auditor, Email, Department and also gets it's primary ID*/
Set(IdAuditVar;Patch(Vistorias;Defaults(Vistorias);
{
Responsavel:AuditorNameTextInput.Text;
Email:AuditorEmailTextInput.Text;
Cidade:CidadeDropdown.Selected.Value;
Endereço: EnderecoDropdown.Selected.Value;
Criado:NowVar
}).ID);;

/* This is the beginning of Q1 code*/
/* This section saves Q1 and then get's it's primary ID which is used to save its images*/
Set(IdQ1Var; Patch(VistoriasRespostas;Defaults(VistoriasRespostas);
{
IDVistoria:IdAuditVar;
IDPergunta:1;
Resposta:DataCardQ1Radio.Selected.Value;
Comentario:DataCardQ1CommentTextInput.Text
}).IDPergunta);;

/* This section saves all the images for Q1*/
ForAll(PictureCol1;Patch(VistoriasFotos;Defaults(VistoriasFotos);{
IDResposta:IdQ1Var;
Imagem:Image
}));;
/* This is the end of Q1 code*/

/* This is the beginning of Q2 code*/
/* This section saves Q2 and then get's it's primary ID which is used to save its images*/
Set(IdQ2Var; Patch(VistoriasRespostas;Defaults(VistoriasRespostas);
{
IDVistoria:IdAuditVar;
IDPergunta:2;
Resposta:DataCardQ2Radio.Selected.Value;
Comentario:DataCardQ2CommentTextInput.Text
}).IDPergunta);;

/* This section saves all the images for Q2*/
ForAll(PictureCol2;Patch(VistoriasFotos;Defaults(VistoriasFotos);{
IDResposta:IdQ2Var;
Imagem:Image
}))
/* This is the end of Q2 code*/
/*This is the end of the Patch fuction*/

;;Set(SubmitVar;false)
;;Reset(AuditorNameTextInput);;Reset(AuditorEmailTextInput);;Reset(CidadeDropdown)
;;Reset(DataCardQ1Radio);;Reset(DataCardQ1CommentTextInput)
;;Reset(DataCardQ2Radio);;Reset(DataCardQ2CommentTextInput)
;;Clear(PictureCol1);;Clear(PictureCol2)

 

 

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @alessandramaced ,

     

    Do you want to avoid creating a patch for each question to simplify duplicated code?

     

    You could create a collection to save the data of questions and use a ForAll function to patch each record in the collection.

     

    The code looks like this:

    Set(IdAuditVar,Patch(Vistorias,Defaults(Vistorias),
    {
    Responsavel:AuditorNameTextInput.Text,
    Email:AuditorEmailTextInput.Text,
    Cidade:CidadeDropdown.Selected.Value,
    Endereço: EnderecoDropdown.Selected.Value,
    Criado:NowVar
    }).ID);
    ClearCollect(tmpColl, {IDPerguntaTMP:1,RespostaTMP:DataCardQ1Radio.Selected.Value,ComentarioTMP:DataCardQ1CommentTextInput.Text},
    {IDPerguntaTMP:2,RespostaTMP:DataCardQ2Radio.Selected.Value,ComentarioTMP:DataCardQ2CommentTextInput.Text});
    ForAll(tmpColl,
    Patch(VistoriasRespostas,Defaults(VistoriasRespostas),
    {
    IDVistoria:IdAuditVar,
    IDPergunta:IDPerguntaTMP,
    Resposta:RespostaTMP,
    Comentario: ComentarioTMP
    });
    ForAll(tmpColl,
    ForAll(PictureCol1,Patch(VistoriasFotos,Defaults(VistoriasFotos),{
    IDResposta:IDPerguntaTMP,
    Imagem:Image
    })));
    Set(SubmitVar,false);
    Reset(AuditorNameTextInput);Reset(AuditorEmailTextInput);Reset(CidadeDropdown);
    Reset(DataCardQ1Radio);Reset(DataCardQ1CommentTextInput);
    Reset(DataCardQ2Radio);Reset(DataCardQ2CommentTextInput);
    Clear(PictureCol1);Clear(PictureCol2)

     

    Best regards,

  • alessandramaced Profile Picture
    308 on at

    Hi, what I want is a code to patch all answers for questions that I have in sharepoint list no matter if I create more questions in future. A formula that identify question, question +1, ...... to end of questions automatically.

     

    In you formula you create a collection but you refer to question 1 and question 2, I still have to know and refer all questions I have. Is that possible to patch all questions no matter and refer one by one?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard