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 / Error when patching – ...
Power Apps
Answered

Error when patching – “The right side of the Equal operator must be a constant value”

(0) ShareShare
ReportReport
Posted on by 4

Hi everyone,

 

I’m building a Power Apps app that consumes freight shipment data from an API via Power Automate. The flow returns JSON, which I parse in Power Apps. From that parsed data I flatten the events, build a timeline (colTimelineUnique), and create a deduplicated list of containers (colUniqueContainers).

 

On my search icon OnSelect, I run the flow, parse the JSON, flatten the events, and build the timeline. On my upload icon OnSelect, I want to take the flattened timeline (colTimelineUniqueEnhanced) and patch it into my Dataverse table Shipment Statuses so that each timeline entry updates or creates a record with:

 
  • Status Name

  • Related Sea Freight Container

  • Related Location

  • Related Vessel


  •  
 

Here’s the relevant part of my formula:


ForAll(
    colTimelineUniqueEnhanced,
    Patch(
        'Shipment Statuses',
        Coalesce(
            First(
                Filter(
                    'Shipment Statuses',
                    'Sea Freight Container'.'Container Number' = ThisRecord.'Sea Freight Container'.'Container Number' &&
                    'Status Name' = ThisRecord.'Status Name' &&
                    Location.'Location Name' = ThisRecord.Location.'Location Name'
                )
            ),
            Defaults('Shipment Statuses')
        ),
        {
            'Status Name': ThisRecord.StatusName,
            'Sea Freight Container': LookUp(
                'Sea Freight Containers',
                'Container Number' = ThisRecord.'Container Number'
            ),
            Location: LookUp(
                Locations,
                'Location Name' = ThisRecord.'Location Name'
            ),
            Vessel: LookUp(
                Vessels,
                'Vessel Name' = ThisRecord.'Vessel Name'
            )
        }
    )
)

The problem is that I get the error:

“The right side of the Equal operator must be a constant value.”

 

 

 

What I think is happening:

Power Apps doesn’t allow me to compare record references directly (e.g. 'Sea Freight Container'.'Container Number' = ThisRecord.'Sea Freight Container'.'Container Number'). The right-hand side must be a constant, variable, or a flattened field value.

 

My question:

How can I correctly patch the flattened values (ContainerNumber, StatusName, LocationName, VesselName) into Shipment Statuses so that existing records are updated and new ones created when no match exists?


Any guidance or examples will be appreciated.
 
I have the same question (0)
  • WarrenBelz Profile Picture
    154,494 Most Valuable Professional on at
    A couple of things caught my attention, particularly these two functions
    Sea Freight Container'.'Container Number' = ThisRecord.'Sea Freight Container'.'Container Number'
    . . . . . . . .
    Location.'Location Name' = ThisRecord.Location.'Location Name'
    
    and 
    'Container Number' = ThisRecord.'Container Number'
    . . . . .
    'Location Name' = ThisRecord.'Location Name'
    
    So your field in the collection cannot be both (compound at the top and a single value at the bottom). I suspect the bottom references are the right ones. Also (and I cannot see your data, so I might be wrong here) you are patching what appears to be a Record value into individual fields (your LookUps return records).
     
    Also while I was at it, I have included a few other suggestions on "pre-defining" things to keep calculations out of the Patch.
    ForAll(
       colTimelineUniqueEnhanced As _Data,
       With(
          {
             _SFC:
             LookUp(
                'Sea Freight Containers',
                'Container Number' = _Data.'Container Number'
             ).YourFieldName,
             _Loc: 
             LookUp(
                Locations,
                'Location Name' = _Data.'Location Name'
             ).YourFieldName,
             _Vessel: 
             LookUp(
                Vessels,
                'Vessel Name' = _Data.'Vessel Name'
             ).YourFieldName,
             _Record:
             LookUp(
                'Shipment Statuses',
                'Sea Freight Container'.'Container Number' = _Data.'Container Number' &&
                'Status Name' = _Data.'Status Name' &&
                Location.'Location Name' =_Data.'Location Name'
             )
          },
          Patch(
             'Shipment Statuses',
             Coalesce(
                _Record,
                Defaults('Shipment Statuses')
             ),
             {
                'Status Name': _Data.StatusName,
                'Sea Freight Container': _SFC,
                Location: _Loc,
                Vessel: _Vessel
             }
          )
       )
    )
     
    Please Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • SN-16021118-0 Profile Picture
    4 on at
    Hi @WarrenBelz,
     

    Thanks for taking the time to walk through my formula — your explanation about record vs. scalar values made a lot of sense. To give you the full picture, here’s the code I’m running to build the collections before the patch step:


    // Run the flow once and store the JSON result in a variable
    Set(
        varFlowResult,
        containerFlow.Run({text: SearchInput1_2.Text}).containerevents
    );
    
    // LEFT GALLERY
    // Parse JSON into base collection
    ClearCollect(
        colContainerEvents,
        Table(ParseJSON(varFlowResult))
    );
    
    // Extract container references (only EQ)
    Clear(tempAllContainers);
    ForAll(
        colContainerEvents As CurrentEvent,
        ForAll(
            Filter(
                Table(CurrentEvent.Value.References),
                Value.referenceType = "EQ" && !IsBlank(Text(Value.referenceValue))
            ) As FilteredReference,
            Collect(
                tempAllContainers,
                {
                    ContainerValue: Text(FilteredReference.Value.referenceValue),
                    ReferenceValue: Text(FilteredReference.Value.referenceValue)
                }
            )
        )
    );
    
    // Deduplicate container list
    ClearCollect(
        colUniqueContainers,
        Distinct(tempAllContainers, ContainerValue)
    );
    
    // RIGHT GALLERY
    // Flatten raw events
    ClearCollect(
        colEventsFlat,
        AddColumns(
            colContainerEvents,
            EventType, Upper(Text(ThisRecord.Value.EventType)),
            CodeT, Upper(Coalesce(Text(ThisRecord.Value.TransportCode), Text(ThisRecord.Value.EquipmentCode))),
            LocationT, Text(ThisRecord.Value.Location),
            VesselT, Text(ThisRecord.Value.Vessel),
            ClassifierT, Upper(Text(ThisRecord.Value.eventClassifierCode)),
            SealNumberT, Text(ThisRecord.Value.SealNumber), 
            ActualArrivalT, DateTimeValue(Left(Text(ThisRecord.Value.ActualDateTime),19)),
            ClassifierRank, Switch(
                Upper(Text(ThisRecord.Value.eventClassifierCode)),
                "ACT", 3,
                "EST", 2,
                "PLN", 1,
                0
            ),
            DisplayDT, DateTimeValue(
                Left(
                    Coalesce(
                        Text(ThisRecord.Value.ActualDateTime),
                        Text(ThisRecord.Value.EstimatedDateTime),
                        Text(ThisRecord.Value.PlannedDateTime),
                        Text(ThisRecord.Value.DateTime)
                    ),
                    19
                )
            ),
            EventCreatedDT, DateTimeValue(Left(Text(ThisRecord.Value.EventCreated), 19)),
            EventKeyT, Text(ThisRecord.Value.eventKey),
            ContainerNumber, Text(First(Filter(Table(ThisRecord.Value.References), Value.referenceType="EQ")).Value.referenceValue)
        )
    );
    
    // Filter transport/equipment events
    ClearCollect(
        colEventsFE,
        Filter(
            colEventsFlat,
            EventType in ["TRANSPORT","EQUIPMENT"] &&
            !IsBlank(CodeT)
        )
    );
    
    // Build timeline with best candidate per EventKey
    ClearCollect(
        colTimelineUnique,
        ForAll(
            Distinct(colEventsFE, EventKeyT) As D,
            With(
                {Candidates: Filter(colEventsFE, EventKeyT = D.Value)},
                With(
                    {Best: First(
                        SortByColumns(
                            Candidates,
                            "ClassifierRank", SortOrder.Descending,
                            "EventCreatedDT", SortOrder.Descending,
                            "DisplayDT", SortOrder.Descending
                        )
                    )},
                    {
                        EventKey: Best.EventKeyT,
                        Code: Best.CodeT,
                        EventType: Best.EventType,
                        Classifier: Best.ClassifierT,
                        ClassRank: Best.ClassifierRank,
                        Location: Best.LocationT,
                        Vessel: Best.VesselT,
                        SealNumber: Best.SealNumberT,
                        DisplayDT: Best.DisplayDT,
                        ActualArrival: Best.ActualArrivalT,
                        ContainerNumber: Best.ContainerNumber
                    }
                )
            )
        )
    );

    So I do have flattened fields like ContainerNumber, LocationT, VesselT etc. in my collections.

     

    The challenge is that when I try your suggested patch formula, I still get the same “The right side of the Equal operator must be a constant value” error. It seems Power Apps is still treating the lookup comparisons ('Sea Freight Container'.'Container Number' = _Data.ContainerNumber) as invalid, even though _Data.ContainerNumber is a text field.

    I’ve also included a picture of the UI so you can see how the galleries and timeline are structured — hopefully that helps clarify how the collections are being used.

    I suspect the issue might be that the lookup column in Dataverse (Sea Freight Container) is a record reference, and Power Apps doesn’t allow direct field comparisons inside a Filter on that type. Flattening works fine for my collections, but the Dataverse side still expects a record rather than a scalar.

    Do you have any suggestions on how to restructure the LookUp/Filter so that I can match on the related record’s field value without hitting this constant‑value restriction?

     

    Thanks again for your help — your breakdown has already clarified a lot, and I think I’m close to getting this working.

  • Verified answer
    WarrenBelz Profile Picture
    154,494 Most Valuable Professional on at
    As you can understand, I cannot see your data or structure, but the ideal comparision method on a filter is to have a String/Number/Date (single) value on each side. The first thing I recommend is to look in colTimelineUniqueEnhanced and see what is in both 'Container Number' and 'Sea Freight Container'.'Container Number' (I suspect only one will exist) then do a collection on 'Shipment Statuses'
    ClearCollect(
       colTemp,
       'Shipment Statuses'
    )
    and see what it returns in the 'Container Number' field.
     
    The anomoly I see here is that this works
    'Sea Freight Container': 
    LookUp(
       'Sea Freight Containers',
       'Container Number' = ThisRecord.'Container Number'
    ),
    so I suspect text on both sides whereas this does not
    Filter(
       'Shipment Statuses',
       'Sea Freight Container'.'Container Number' = ThisRecord.'Sea Freight Container'.'Container Number' 
    nor effectively neither does this
    Filter(
       'Shipment Statuses',
       'Sea Freight Container'.'Container Number' = ThisRecord.'Container Number' 
    so you need to see what all references actually return.
     
    Please Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard