John S.
asked on
Array Help again - compare and return new one
I recently asked a similar question but left out some important stuff. Here goes again...
Source Array
I have an array of items that looks like the following code. There can and will be many items in here.
I have a second array that looks like this. There will only be one object in this array.
For instance, if I am editing itemID 12345...
So if an item in the source array has two serial numbers, and both were changed, the result would be:
Desired Return Array
Some things to note:
1. rmaId, itemId, upc, name, qty cannot/will not be change.
2. some items may NOT have any serial numbers, so we need to still track notes and description
3. The return array only has those 5 properties, that is deliberate.
THANKS. I way above my paygrade on this one, lol
Source Array
I have an array of items that looks like the following code. There can and will be many items in here.
[
{
"ItemId": "12345",
"rmaId": "777",
"UPC": "73343324400098",
"Name": "Time Machine",
"Description": "A new product you will love",
"SerialNumberRequired": true,
"Notes": "This is a note someone just entered",
"Condition": 2,
"Qty": 2,
"SerialNumber": [
"33",
"34"
]
},
{
// more items will be here
}
]
Edit ArrayI have a second array that looks like this. There will only be one object in this array.
[
{
"ItemId": "12345",
"rmaId": "777",
"UPC": "73343324400098",
"Name": "Time Machine",
"Description": "A new product you will love",
"SerialNumberRequired": true,
"Notes": "This is a note someone just entered",
"Condition": 2,
"Qty": 2,
"SerialNumber": [
"11112222",
"3333344444"
]
}
]
Based on the itemId in Edit array, I need any changes that don't match the source array returned to me in an array in this format. For instance, if I am editing itemID 12345...
So if an item in the source array has two serial numbers, and both were changed, the result would be:
Desired Return Array
[
{
rmaId: "777",
itemId: "12345",
serialNumber: "11112222",
notes: "Some Notes",
condition: "Good"
},
{
rmaId: "777",
itemId: "12345",
serialNumber: "3333344444",
notes: "Some Notes",
condition: "Good"
}
]
Some things to note:
1. rmaId, itemId, upc, name, qty cannot/will not be change.
2. some items may NOT have any serial numbers, so we need to still track notes and description
3. The return array only has those 5 properties, that is deliberate.
THANKS. I way above my paygrade on this one, lol
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER