{"id":"a89dc0c1-0f4d-430d-a4ea-486d1d9f12d5","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Xpath_One_To_Many_Update","operationDefinition":{"type":"Scope","actions":{"Root":{"type":"Compose","inputs":{"root":{"values":"@outputs('Source')"}},"runAfter":{"Source":["Succeeded"]},"description":"Format destination data into JSON ready to convert to XML","metadata":{"operationMetadataId":"bf5bba38-67e5-476b-99ff-9064445783e2"}},"XML":{"type":"Compose","inputs":"@xml(outputs('Root'))","runAfter":{"Root":["Succeeded"]},"metadata":{"operationMetadataId":"2c27d4b7-252e-48ac-99c9-a51fa8b2bf26"}},"Select":{"type":"Select","inputs":{"from":"@outputs('Destination')","select":{"Destination":"@item()","Source":"@if(empty(outputs('settings')['DestinationKeyColumnName2']),\r\n\r\nif(\r\n empty(xpath(outputs('XML'), concat('(//values[', outputs('settings')['SourceKeyColumnName'], '=''', item()?[outputs('settings')['DestinationKeyColumnName']], '''])'))), \r\n json('{}'), \r\n json(xml(join(xpath(outputs('XML'), concat('(//values[', outputs('settings')['SourceKeyColumnName'], '=''', item()?[outputs('settings')['DestinationKeyColumnName']], '''])[', if(equals('last', toLower(outputs('settings')['MatchFirstOrLastSource'])),'last()', 1), ']')), '')))?['values']\r\n),\r\nif(\r\n empty(xpath(outputs('XML'), concat('(//values[', outputs('settings')['SourceKeyColumnName'], '=''', item()?[outputs('settings')['DestinationKeyColumnName']], ''' and ', outputs('settings')['SourceKeyColumnName2'], '=''', item()?[outputs('settings')['DestinationKeyColumnName2']], '''])'))), \r\n json('{}'),\r\n json(xml(join(xpath(outputs('XML'), concat('(//values[', outputs('settings')['SourceKeyColumnName'], '=''', item()?[outputs('settings')['DestinationKeyColumnName']], ''' and ', outputs('settings')['SourceKeyColumnName2'], '=''', item()?[outputs('settings')['DestinationKeyColumnName2']], '''])[', if(equals('last', toLower(outputs('settings')['MatchFirstOrLastSource'])),'last()', 1), ']')), '')))?['values']\r\n)\r\n)"}},"runAfter":{"XML":["Succeeded"]},"description":"Use xpath( ) to append destination data /w 1st or last source XML records that match a query.","metadata":{"operationMetadataId":"922ebb9c-427c-4198-bb5c-d838ad6723fd"}},"Select_Updated_destination_data":{"type":"Select","inputs":{"from":"@body('Select')","select":{"DestinationId":"@item()?['Destination']?['DestinationId']","DestinationColumnName":"SourceValue","DestinationTitle":"@item()?['Source']?['SourceTitle']","DestinationCode":"@item()?['Source']?['SourceCode']","DestinationDate":"@item()?['Source']?['SourceDate']"}},"runAfter":{"Select":["Succeeded"]},"description":"Destination column names on the left & dynamic content for their new values from source data on the right. But you'll want to keep the destination primary key/ID value. For source values use item()?['Source']?['InsertSourceColumnName']","metadata":{"operationMetadataId":"bbe3a0ef-2827-4b49-b41b-b1caa26e0d12"}},"Source":{"type":"Compose","inputs":[{"SourceId":0,"SourceTitle":"Advil","SourceCode":"A","SourceDate":"2024-01-01"},{"SourceId":1,"SourceTitle":"Advil","SourceCode":"A2","SourceDate":"2024-02-01"},{"SourceId":2,"SourceTitle":"Tums","SourceCode":"B","SourceDate":"2024-01-02"},{"SourceId":3,"SourceTitle":"Aspirin","SourceCode":"C","SourceDate":"2024-01-03"},{"SourceId":4,"SourceTitle":"TestSourceNoMatchTitle","SourceCode":"C","SourceDate":"2024-01-04"},{"SourceId":5,"SourceTitle":"TestSourceNoMatchTitle2","SourceCode":"C","SourceDate":"2024-01-05"}],"runAfter":{"Destination":["Succeeded"]},"description":" To use this for other data, enter dynamic content for a JSON array of all your updated source values","metadata":{"operationMetadataId":"11ef5e2c-93af-4221-bdc5-44083125a026"}},"settings":{"type":"Compose","inputs":{"DestinationKeyColumnName":"DestinationTitle","DestinationKeyColumnName2":"","SourceKeyColumnName":"SourceTitle","SourceKeyColumnName2":"","MatchFirstOrLastSource":"last"},"runAfter":{},"description":"Key columns used to determine which source items update which destination items. 2nd Column names enable matching up items only where both source & both destination columns match. MatchFirstOrLastSource get the \"first\" or \"last\" matching source item","trackedProperties":{"meta":{"type":"SP.Data.@{outputs('settings')?['listName']}ListItem"},"batchGUID":"@{guid()}","changeSetGUID":"@{guid()}"},"metadata":{"operationMetadataId":"459dc501-ad7e-4252-8540-df307a69607f"}},"Destination":{"type":"Compose","inputs":[{"DestinationId":5,"DestinationTitle":"Advil","DestinationCode":null,"DestinationDate":null},{"DestinationId":6,"DestinationTitle":"Advil","DestinationCode":null,"DestinationDate":null},{"DestinationId":7,"DestinationTitle":"Advil","DestinationCode":null,"DestinationDate":null},{"DestinationId":8,"DestinationTitle":"Tums","DestinationCode":null,"DestinationDate":null},{"DestinationId":9,"DestinationTitle":"Tums","DestinationCode":null,"DestinationDate":null},{"DestinationId":10,"DestinationTitle":"Aspirin","DestinationCode":null,"DestinationDate":null},{"DestinationId":11,"DestinationTitle":"TestDestinationNoMatchTitle","DestinationCode":null,"DestinationDate":null}],"runAfter":{"settings":["Succeeded"]},"description":" To use this for other data, enter dynamic content for a JSON array of all your destination values","metadata":{"operationMetadataId":"362ebcba-0149-4194-bcdb-15a890d6fbef"}},"Select_Destination_keys":{"type":"Select","inputs":{"from":"@outputs('Destination')","select":"@if(empty(outputs('settings')['DestinationKeyColumnName2']),\r\nitem()[outputs('settings')['DestinationKeyColumnName']],\r\nconcat(item()[outputs('settings')['DestinationKeyColumnName']],item()[outputs('settings')['DestinationKeyColumnName2']])\r\n)"},"runAfter":{"Select":["Succeeded"]},"metadata":{"operationMetadataId":"b27fbb32-fb83-4597-a3ed-098beea086a5"}},"Filter_array_Source_records_not_in_destination":{"type":"Query","inputs":{"from":"@outputs('Source')","where":"@not(contains(body('Select_Destination_keys'), if(empty(outputs('settings')['SourceKeyColumnName2']), item()[outputs('settings')['SourceKeyColumnName']], concat(item()[outputs('settings')['SourceKeyColumnName']], item()[outputs('settings')['SourceKeyColumnName2']]))))"},"runAfter":{"Select_Destination_keys":["Succeeded"]},"metadata":{"operationMetadataId":"4005a7e4-d07d-4450-ae56-90d81468cc65"}}},"runAfter":{},"description":"For other data, enter key column names in settings, dynamic content for a JSON array of all your destination values in Destination, & of all your Source values in Source. Enter new column names & values in Updated destination data action.","metadata":{"operationMetadataId":"523232c8-465c-423a-a457-f31b339440f3"}}}