Hello!
I'm trying to update an item in an array of objects based on a look up of zone number in another list based on a specific value in the array of objects.
In this Array1, I want to update the Zone value with Zone number using Store Number in Array1 as the LookUpStr value in the list of Zone numbers.
Array1:
[
{
"Store Number": 141,
"Store Name": "test name",
"Price": 3.99,
"Price Type": "ZONE",
"Price Start Date": "2024-03-18T00:00:00",
"Promotion Type": null,
"Promotional Price": 3.99,
"Promotion Start Date": "2024-03-18T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": ""
},
{
"Store Number": 111,
"Store Name": "test name2",
"Price": 3.99,
"Price Type": "ZONE",
"Price Start Date": "2024-03-18T00:00:00",
"Promotion Type": null,
"Promotional Price": 3.99,
"Promotion Start Date": "2024-03-18T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": ""
},
{
"Store Number": 57,
"Store Name": "test name3",
"Price": 3.33,
"Price Type": "ZONE",
"Price Start Date": "2024-12-28T00:00:00",
"Promotion Type": "S",
"Promotional Price": 3.33,
"Promotion Start Date": "2024-12-28T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": ""
},
{
"Store Number": 73,
"Store Name": "test City",
"Price": 3.99,
"Price Type": "ZONE",
"Price Start Date": "2024-12-28T00:00:00",
"Promotion Type": "I",
"Promotional Price": 3.49,
"Promotion Start Date": "2024-12-28T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": "SC22111",
"Price Status": "CUR",
"Zone": ""
},
{
"Store Number": 124,
"Store Name": "test Hill",
"Price": 2.22,
"Price Type": "ZONE",
"Price Start Date": "2024-12-30T00:00:00",
"Promotion Type": "T",
"Promotional Price": 2.22,
"Promotion Start Date": "2024-12-30T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": ""
}
]
Look up list array for zone number by LookUpStr:
[
{
"Zone": "1",
"LookUpStr": "3"
},
{
"Zone": "2",
"LookUpStr": "1"
},
{
"Zone": "3",
"LookUpStr": "80"
},
{
"Zone": "4",
"LookUpStr": "45"
},
{
"Zone": "5",
"LookUpStr": "157"
},
{
"Zone": "6",
"LookUpStr": "8"
},
{
"Zone": "7",
"LookUpStr": "129"
},
{
"Zone": "8",
"LookUpStr": "7"
},
{
"Zone": "9",
"LookUpStr": "14"
},
{
"Zone": "11",
"LookUpStr": "36"
},
{
"Zone": "12",
"LookUpStr": "69"
},
{
"Zone": "13",
"LookUpStr": "76"
},
{
"Zone": "14",
"LookUpStr": "124"
},
{
"Zone": "15",
"LookUpStr": "73"
},
{
"Zone": "16",
"LookUpStr": "57"
},
{
"Zone": "17",
"LookUpStr": "127"
},
{
"Zone": "18",
"LookUpStr": "120"
},
{
"Zone": "19",
"LookUpStr": "108"
},
{
"Zone": "20",
"LookUpStr": "111"
},
{
"Zone": "21",
"LookUpStr": "141"
},
{
"Zone": "22",
"LookUpStr": "143"
},
{
"Zone": "23",
"LookUpStr": "119"
}
]
Sample desired results:
Because the first record in Array1 has store number 141, its Zone is 21. See zone list array above.
Because the second record has store number 111, its Zone is 20.
Because the third record has store number 57, its Zone is 16.
And so on ...
[
{
"Store Number": 141,
"Store Name": "test name",
"Price": 3.99,
"Price Type": "ZONE",
"Price Start Date": "2024-03-18T00:00:00",
"Promotion Type": null,
"Promotional Price": 3.99,
"Promotion Start Date": "2024-03-18T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": "21"
},
{
"Store Number": 111,
"Store Name": "test name2",
"Price": 3.99,
"Price Type": "ZONE",
"Price Start Date": "2024-03-18T00:00:00",
"Promotion Type": null,
"Promotional Price": 3.99,
"Promotion Start Date": "2024-03-18T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": "20"
},
{
"Store Number": 57,
"Store Name": "test name3",
"Price": 3.33,
"Price Type": "ZONE",
"Price Start Date": "2024-12-28T00:00:00",
"Promotion Type": "S",
"Promotional Price": 3.33,
"Promotion Start Date": "2024-12-28T00:00:00",
"Promotion End Date": "2025-01-31T00:00:00",
"Coupon Number": null,
"Price Status": "CUR",
"Zone": "16"
},
Thanks for any suggestions!