cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fbarini
Helper I
Helper I

Multiple Patches with one click?

Hello everyone!

 

I made this form for hiring requests and initially, the client needed asked for a "Quantity" field. Now, the client also wants to link each request to the hired person by the end of the process, which bring us our problem.

 

Considering someone inputs the number 2 on the quantity field, we wouldn't be able to link each of the hired person to their own request ID, since we would only have 1. So, in my head, an option would be to execute my Patch button X times (depending on the number input on the Quantity field). Does anyone know any way to achieve this? Or if this is even possible?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

Hi @fbarini

 

1. Your Patch command will be

ForAll(
    Sequence(Value(QtyInput.Text)),
    Patch(
        BaseAppRH,
        Defaults(BaseAppRH),
        {IDNum: Value(InfoID.Text)}
    )
)

 

Recommendation

2. Error Notification. Set your error notification code on OnFailure property of EditForm Property

3. Set your Update and Send an email code on OnSucess property of Editform property

 

Example:

StalinPonnusamy_0-1632144372750.png

 

View solution in original post

5 REPLIES 5
Kosenurm
Helper V
Helper V

Hi @fbarini 

 

This sounds possible. Can you share some images to bring it to life a bit please, as well as your current patch code?

 

Thanks

K.

Hello K. Please, see below... (Quite extense tho)

 

The form. (Patch Button is by the end of screen)

fbarini_0-1632143106460.png

 

 

 

// MAKE CANVAS FOCUS ON THE FIRST FIELD AFTER PATCH //
SetFocus(TextoQtdVagas);;
// PATCH INFO //
Patch(
    BaseAppRH;
    Defaults(BaseAppRH);
    {
        IDNum: Value(InfoID.Text);
        TesteData: DataCriacao.Text;
        Area: DDArea.Selected.Result;
        Cargo: DDCargo.Selected.Result;
        Unidade: DDUnidade.Selected.Result;
        CentrodeCusto: DDCentroDeCusto.Selected.Result;
        TipodeVaga: DDTipoDeVaga.Selected.Value;
        SugereFuncion_x00e1_rio_x003f_: NomeSubstituido.Text;
        CargaHor_x00e1_ria: RadioCargaHoraria.Selected.Value;
        Turno: DDTurno.Selected.Result;
        ConsideracoesdaVaga: ConsideracoesVaga1.Text;
        Escolaridade: DDEscolaridade.Selected.Value;
        QualificacoesAdicionais: QualificacoesAdicionais.Text;
        Notebook_x003f_: If(
            CheckBoxNote.Value = true;
            "Sim";
            "Não"
        );
        Celular_x003f_: If(
            CheckBoxCel.Value = true;
            "Sim";
            "Não"
        );
        SAP_x003f_: If(
            CheckBoxSAP.Value = true;
            "Sim";
            "Não"
        );
        TOTVS_x003f_: If(
            CheckBoxTotvs.Value = true;
            "Sim";
            "Não"
        );
        QtdVagas: TextoQtdVagas.Text;
        E_x002d_MaildoCriador: User().Email;
        OutrosAlmox: CampoOutrosAlmox.Text;
        OutrosTI: CampoOutroTI.Text;
        SapatoSeguran_x00e7_a: If(
            CheckBoxSapato.Value = true;
            "Sim";
            "Não"
        );
        Uniforme: If(
            CheckBoxUniforme.Value = true;
            "Sim";
            "Não"
        );
        Aprovacao1: LookUp(
            TabelaCargos;
            Unidade_x0026_Area_x0026_Cargo = DDUnidade.Selected.Result & DDArea.Selected.Result & DDCargo.Selected.Result
        ).Aprov1;
        Aprovacao2: LookUp(
            TabelaCargos;
            Unidade_x0026_Area_x0026_Cargo = DDUnidade.Selected.Result & DDArea.Selected.Result & DDCargo.Selected.Result
        ).Aprov2;
        Aprovacao3: LookUp(
            TabelaCargos;
            Unidade_x0026_Area_x0026_Cargo = DDUnidade.Selected.Result & DDArea.Selected.Result & DDCargo.Selected.Result
        ).Aprov3;
        SolEmail: If(
            CheckBoxEmail.Value = true;
            "Sim";
            "Não"
        );
        CheckBoxOutrosTI: CheckBoxOutrosTI.Value;
        CheckBoxOutrosAlmox: CheckBoxOutros.Value
    }
);;
// Patch Test //
If(
    IsEmpty(Errors(BaseAppRH));
    Navigate(
        Landing;
        ScreenTransition.CoverRight
    );;
    Notify(
        "Solicitação Enviada com Sucesso!";
        NotificationType.Success;
        2000
    );;
    UpdateContext({ResetVar: true});;
    UpdateContext({ResetVar: false});
    Notify(
        "Preencha Todos os Campos";
        NotificationType.Error;
        2000
    )
);;
// UPDATE RECORD IF APROOVER 1 DOESN'T EXIST //
UpdateIf(
    BaseAppRH;
    IsBlank(Aprovacao1) && StatusAprov_x002e_1 = "Em Análise";
    {
        StatusAprov_x002e_1: "Aprovado";
        StatusAprov_x002e_2: "Em Análise";
        DataAprov_x002e_1: Text(
            Now();
            "mm/dd/yyyy hh:mm:ss"
        );
        Aprovador1: "Automático"
    }
);;
Office365Outlook.SendEmail(
    If(
        !IsBlank(Last(BaseAppRH).Aprovacao1);
        Last(BaseAppRH).Aprovacao1;
        If(
            !IsBlank(Last(BaseAppRH).Aprovacao2);
            Last(BaseAppRH).Aprovacao2;
            Last(BaseAppRH).Aprovacao3
        )
    );
    "Nova Aprovação de Vaga Disponível";
    "A vaga " & Last(BaseAppRH).ID & " foi criada pelx " & User().FullName & ". Para  aprovar ou reprovar, clique no link ou entre pelo app. " & "https://apps.powerapps.com/
)

 

 

Thanks in advance

StalinPonnusamy
Community Champion
Community Champion

Hi @fbarini

 

1. Your Patch command will be

ForAll(
    Sequence(Value(QtyInput.Text)),
    Patch(
        BaseAppRH,
        Defaults(BaseAppRH),
        {IDNum: Value(InfoID.Text)}
    )
)

 

Recommendation

2. Error Notification. Set your error notification code on OnFailure property of EditForm Property

3. Set your Update and Send an email code on OnSucess property of Editform property

 

Example:

StalinPonnusamy_0-1632144372750.png

 

View solution in original post

Thank you for the direction! It worked on the first try!!

 

Thanks for the reccomendations as well. Sadly, when I first created the form, I created it from a blank screen, and not from a Form itself, so I won't have those options you mentioned.

 

fbarini_0-1632166477788.png

 

Is using the "Default" Forms a best practice for Power Apps when building forms?

 

Thanks again

StalinPonnusamy
Community Champion
Community Champion

Hi @fbarini 

 

There is no difference between the default vs user-built it from scratch. To have an form

 

  • Insert the form control by clicking Insert > Forms > Edit

StalinPonnusamy_0-1632167466173.png

  • Set the Data Source
  • Click "Edit fields" to add the fields that you want to have on the form

StalinPonnusamy_1-1632167579059.png

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,364)