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 Platform Community / Forums / Power Apps / How can i delegate thi...
Power Apps
Unanswered

How can i delegate this lookup to work on big data list

(0) ShareShare
ReportReport
Posted on by 18

My formula is actually like this, i tried all solutions i can find. i want to patch an item on my SP but not a duplicate, by making a lookup before the patch, but the lookup doenst work.

ForAll(
Filter(QualinetGAL.AllItems; !IsBlank(CONTRATOGAL.Text));
If(
IsBlank(
LookUp(
'TAP LOTADO - TP1 V2';
CONTRATO = CONTRATOGAL.Text && 'DATA OC QUALINET' = DateTimeValue(DATAOCGAL.Text)
).CONTRATO
);
Patch(
'TAP LOTADO - TP1 V2';
Defaults('TAP LOTADO - TP1 V2');
{
INCIDENTE: "PREENCHER";
DEFINICAO: "VALIDAR OC";
CIDADE: CIDADEGAL.Text;
UF: UFGAL.Text;
CONTRATO: CONTRATOGAL.Text;
'DATA OC QUALINET': DateTimeValue(DATAOCGAL.Text);
ENDERECO: ENDERECOGAL.Text;
NODE: NODEGAL.Text
}
)
)
);;
Clear(QualinetTot);;Reset(QualinetTextos)

Categories:
  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    Hi @FaresNunes ,

    Try this for a start

    With(
     {_Date: DateTimeValue(DATAOCGAL.Text)};
     With(
     {
     _New:
     IsBlank(
     LookUp(
     'TAP LOTADO - TP1 V2';
     CONTRATO = CONTRATOGAL.Text && 
     'DATA OC QUALINET' = _Date
     ).CONTRATO
     )
     },
     ForAll(
     Filter(
     QualinetGAL.AllItems;
     !IsBlank(CONTRATOGAL.Text)
     ) As _Data;
     If(
     _New;
     Patch(
     'TAP LOTADO - TP1 V2';
     Defaults('TAP LOTADO - TP1 V2');
     {
     INCIDENTE: "PREENCHER";
     DEFINICAO: "VALIDAR OC";
     CIDADE: _Data.CIDADEGAL.Text;
     UF: _Data.UFGAL.Text;
     CONTRATO: _Data.CONTRATOGAL.Text;
     'DATA OC QUALINET': _Date;
     ENDERECO: _Data.ENDERECOGAL.Text;
     NODE: _Data.NODEGAL.Text
     }
     )
     )
     )
     )
    );;
    Clear(QualinetTot);;
    Reset(QualinetTextos)

    If any of those Text controls are not in the gallery, remove _Data from them.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • FaresNunes Profile Picture
    18 on at

    They are all in the galley but now its returning DATAOCQUALINET is obrigatory on patch

  • FaresNunes Profile Picture
    18 on at

    FaresNunes_0-1709586276296.pngFaresNunes_1-1709586301157.png

    im getting a network error, and i dont know why, the code is just like you said

  • FaresNunes Profile Picture
    18 on at

    FaresNunes_0-1709586554063.png

    i just turn off mandatory DATAOCQUALINET on SP list and then the code works, but keep patching duplicate to SP list

  • FaresNunes Profile Picture
    18 on at

    What i want is that for every item in my gallery i check the item CONTRATOGAL label text and DATAOCGAL label text, if they have a clone on my SP list and then if not patch the gallery item on SP, but first the lookup inst working and now it works but on some point i miss on the formula and the patch is cloning items anyway

  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    @FaresNunes ,

    I assume 'DATA OC QUALINET' is a Date field in SharePoint. Where is DATAOCGAL situated (inside or outside of the gallery), how is it populated and why do you need to convert it with DateValue ?

  • FaresNunes Profile Picture
    18 on at

    Yes 'DATA OC QUALINET' is a Date field in SharePoint, cause i need to calculate some Date differences in the app, but now i changed the code creating a new column on SP to control date text and compare on lookup, i read the docs and see that Date type fields are not delegable, my date is populated by a text from a sheet that i convert into Date Type to patch on SP, so i created a new field Text Type to insert the date as text, but it doenst work as well.
    Look at the code:

    With(
    {_Date: DATAOCGAL.Text};
    With(
    {
    _New:
    IsBlank(
    LookUp(
    'TAP LOTADO - TP1 V2';
    CONTRATO = CONTRATOGAL.Text &&
    'CTRL DATA QUALINET' = _Date
    )
    )
    };
    ForAll(
    Filter(
    QualinetGAL.AllItems;
    !IsBlank(CONTRATOGAL.Text)
    ) As _Data;
    If(
    _New;
    Patch(
    'TAP LOTADO - TP1 V2';
    Defaults('TAP LOTADO - TP1 V2');
    {
    INCIDENTE: "PREENCHER";
    DEFINICAO: "VALIDAR OC";
    CIDADE: _Data.CIDADEGAL.Text;
    UF: _Data.UFGAL.Text;
    CONTRATO: _Data.CONTRATOGAL.Text;
    'CTRL DATA QUALINET': DATAOCGAL.Text;
    'DATA OC QUALINET': DateTimeValue(DATAOCGAL.Text);
    ENDERECO: _Data.ENDERECOGAL.Text;
    NODE: _Data.NODEGAL.Text
    }
    )
    )
    )
    )
    );;
    Clear(QualinetTot);;
    Reset(QualinetTextos)

    i need to compare the "CONTRATO" field and the TEXT of DATA OC QUALINET that i created a column "CTRL DATA QUALINET" to it, but the app keep patching duplicate to SP.

  • FaresNunes Profile Picture
    18 on at

    DATAOCGAL is inside the gallery, in a label

  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    @FaresNunes ,

    Firstly Dates in SharePoint are Delegable, so the conversion to Text and back is actually adding complexity you do not need. Just add a Date Picker and directly Patch the content of this. Also this piece of code

    ForAll(
     Filter(
     QualinetGAL.AllItems;
     !IsBlank(CONTRATOGAL.Text)
     ) As _Data;

    creates a new record for every record in the gallery Qualinet where the CONRTATOGAL control is not blank, so I suspect there is more than one record in the gallery that matches this. 

  • FaresNunes Profile Picture
    18 on at

    The actual code is like this, if i remove the !IsBlank you think it should work? i have that to not patch any empty value on SP, but i dont think i do it the best way

    With(
    {_Date: DateTimeValue(DATAOCGAL.Text)};
    With(
    {
    _New: IsBlank(
    LookUp(
    'TAP LOTADO - TP1 V2';
    CONTRATO = CONTRATOGAL.Text && 'DATA OC QUALINET' = _Date
    ).CONTRATO
    )
    };
    ForAll(
    Filter(
    QualinetGAL.AllItems;
    !IsBlank(CONTRATOGAL.Text)
    ) As _Data;
    If(
    _New;
    Patch(
    'TAP LOTADO - TP1 V2';
    Defaults('TAP LOTADO - TP1 V2');
    {
    INCIDENTE: "PREENCHER";
    DEFINICAO: "VALIDAR";
    CIDADE: _Data.CIDADEGAL.Text;
    UF: _Data.UFGAL.Text;
    CONTRATO: _Data.CONTRATOGAL.Text;
    'DATA OC QUALINET': DateTimeValue(DATAOCGAL.Text);
    ENDERECO: _Data.ENDERECOGAL.Text;
    NODE: _Data.NODEGAL.Text
    }
    )
    )
    )
    )
    );;
    Clear(QualinetTot);;
    Reset(QualinetTextos)

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard