30
Views
7
Comments
Solved
How to conditional update of local record?
Question
Application Type
Mobile
Service Studio Version
11.10.7 (Build 37468)

I finished the Mobile Development guided path training...but I'm still a novice. Bear with me, please.

Using an Accelerator ("UpdateLocalPriceSpecForSync" in this case) I'm attempting to update a field in a local record with a value from a local variable ("HolidayFactor" in this case), and I'm trying to choose the specific record for update based on a condition - that the local record's date equals a date in the "PriceSpecNight" local variable. It's not working; Outsystems reports that "Record to update does not exist on table..." despite the fact that I can see the record in a screen list while using the Android device emulator - I know it's there, despite the "Record to update..." error's claim. What am I missing?



Rank: #5680
Solution

I appreciate all your help.  Unfortunately, I'm out of time for continuing to learn through this hands-on Outsystems dev effort, for now.

I've tried a whole bunch of different methods...and nothing is working.

I've isolated the problem to addition of a Filter in the Aggregate that's supposed to get the record for updating. Before adding a Filter, the Aggregate will bring back records, and the update works just fine. But...when I modify the Aggregate, by adding a Filter that uses a local variable's value, the Aggregate brings back nothing...regardless of the variable's value, and this is despite 1.) confirming (using the Debugger) the local variable does contains a value (a date) corresponding to an existing record's date, and 2.) confirming (using a List Widget in a screen, and viewing the record in question) that the record with corresponding date does exist in the table. I'm stumped....and will have to come back to this when I have more time to spend on learning Outsystems. There's not a lot of complexity here...and I simply cannot understand why the Aggregate fails despite confirming conditions are right for retrieving a record. Frustrating....... Thanks again for your help.

mvp_badge
MVP
Rank: #2

Hi Matt,

Can you post your module? It's a bit difficult seeing what's wrong without the actual code. Also, you may want to put some of that code inside the For Each in its own Action, this is not the most clear code ever ;).

Rank: #301

Hi Matt,

Are you trying to insert and update the record at the same time? It might be a possibility that you are trying to update a record before it get inserted and available into the particular entity for update action?

Thanks & Kind Regards,

Sachin

Rank: #5680

Thanks for your time, Kilian and Sachin. I appreciate the help, as I learn Outsystems. Note that I don't have history as a software developer. Rather, i'm a "spreadsheet jockey". That's not an excuse...just a fact to be aware of....

As a novice, I've never posted a module; I'll look for instructions. Until then, here's a quick overview of my messy work :)

A list (table) of holiday records were created in a prior step/module. I can see  the records in both the server and local tables. Each holiday record specifies U.S. holidays that are either "major" or "minor" holidays (using a Boolean, set early in this flow, after the 'for each'), providing an attribute central to business logic that's used to update hotel-room nightly pricing-specification records in another table (LocalPriceSpec).

We update the PriceSpec records based on date; there's one PriceSpec record for each date of the year (i.e., 365 PriceSpec records).

The GetHolidayList 'for each' cycles through each holiday record, and the holiday's date is set in a local variable ("PriceSpecNight"). Then, the objective is to get and update LocalPriceSpec records (using the UpdateLocalPriceSpecForSync Client Action). This Client Action references a query (GetLocalPriceSpec) that contains a filter referencing the holiday's date, and it uses the date to identify (and get) the one LoalPriceSpec record.

So...I'm wondering: could it be that the GetLocalPriceSpec query isn't executed from within the UpdateLocalPriceSpecForSync Client Action? Do I need to explicitly trigger the query and then pass the resulting record into the Client Action?

Rank: #5680

I hope this is sufficient for diagnosing the issue.  I dragged both the CORE and Consumer modules onto to this thread...but I only see the Consumer module. You'll find the offending "ApplyFactorsOnClick" Client Action under the Holidays screen.

MBIAdminCORE.oml

Rank: #301

Hi Matt,

I am not able to download this OML. Could you please verify and reattach the correct one?

Thanks & Kind Regards,

Sachin

Hi Matt,

Good day!

To confirm if the record exists in the local storage, you can use the dev tools in google chrome.

https://www.outsystems.com/forums/discussion/49078/how-to-see-all-data-record-in-local-storage-on-mobile-application/

I think this is to isolate if the exists in the local storage.

Hope this helps,

Thank you and kind regards,

Chris

Rank: #5680
Solution

I appreciate all your help.  Unfortunately, I'm out of time for continuing to learn through this hands-on Outsystems dev effort, for now.

I've tried a whole bunch of different methods...and nothing is working.

I've isolated the problem to addition of a Filter in the Aggregate that's supposed to get the record for updating. Before adding a Filter, the Aggregate will bring back records, and the update works just fine. But...when I modify the Aggregate, by adding a Filter that uses a local variable's value, the Aggregate brings back nothing...regardless of the variable's value, and this is despite 1.) confirming (using the Debugger) the local variable does contains a value (a date) corresponding to an existing record's date, and 2.) confirming (using a List Widget in a screen, and viewing the record in question) that the record with corresponding date does exist in the table. I'm stumped....and will have to come back to this when I have more time to spend on learning Outsystems. There's not a lot of complexity here...and I simply cannot understand why the Aggregate fails despite confirming conditions are right for retrieving a record. Frustrating....... Thanks again for your help.