This code represents a sequence of logic for a workflow...

August 8, 2025 at 07:42 PM

{ "type": "If", "expression": { "not": { "equals": [ "@outputs('Get_item_ESS_Master_Employee_List_Again')?['body/ConfidentialMemberFolderID']", "@null" ] } }, "actions": { "Get_Confidential_Member_Files_already_there": { "type": "OpenApiConnection", "inputs": { "parameters": { "dataset": "https://surreypoliceservices.sharepoint.com/sites/ESSAdministration", "table": "a64eb8e5-05a4-49bc-884d-06be180f89c6", "id": "@outputs('Get_item_ESS_Master_Employee_List_Again')?['body/ConfidentialMemberFolderID']" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", "connection": "shared_sharepointonline_2", "operationId": "GetFileItem" } }, "metadata": { "operationMetadataId": "3683cb82-c9c2-4918-b719-92ca2ef4e916" } }, "Set_variable_Confidential_Member_File_ID_Get_3": { "type": "SetVariable", "inputs": { "name": "ConfidentialMemberFileIDGetorCreate", "value": "@{outputs('Get_Confidential_Member_Files_already_there')?['body/ID']}" }, "runAfter": { "Get_Confidential_Member_Files_already_there": [ "Succeeded" ] }, "metadata": { "operationMetadataId": "32f0d385-6650-4dc3-b4c0-3bc54801f358" } } }, "else": { "actions": { "Get_Confidential_Member_Doc_Set": { "type": "OpenApiConnection", "inputs": { "parameters": { "dataset": "https://surreypoliceservices.sharepoint.com/sites/ESSAdministration", "table": "a64eb8e5-05a4-49bc-884d-06be180f89c6", "$filter": "EmployeeID eq '@{triggerOutputs()?['body/EmployeeNumber']}' and ContentType eq 'SPSHREmpFileDocSet'", "$top": 1, "view": "d51839e1-dde4-4909-bd26-a53c9001a23f", "viewScopeOption": "RecursiveAll" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", "connection": "shared_sharepointonline", "operationId": "GetFileItems" } }, "metadata": { "operationMetadataId": "20a112bb-2df2-437e-b471-920ddf44150b" } }, "If_User_does_NOT_exist_in_Confidential_Members": { "type": "If", "expression": { "equals": [ "@length(outputs('Get_Confidential_Member_Doc_Set')?['body/value'])", 0 ] }, "actions": { "Create_document_set_folders_2": { "type": "Foreach", "foreach": "@variables('ESSAdminFoldersArray')", "actions": { "Create_new_folder_2": { "type": "OpenApiConnection", "inputs": { "parameters": { "dataset": "https://surreypoliceservices.sharepoint.com/sites/ESSAdministration", "table": "a64eb8e5-05a4-49bc-884d-06be180f89c6", "parameters/path": "@{variables('ConfidentialMemberFoldername')}/@{items('Create_document_set_folders_2')}" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", "connection": "shared_sharepointonline", "operationId": "CreateNewFolder" } }, "metadata": { "operationMetadataId": "02c13d90-5b79-47cc-bf78-2fc0823dd76b" } } }, "runAfter": { "Create_new_document_set": [ "Succeeded" ] }, "metadata": { "operationMetadataId": "27b1a573-9f31-49da-b6ec-bdd740149899" } }, "Create_new_document_set": { "type": "OpenApiConnection", "inputs": { "parameters": { "dataset": "https://surreypoliceservices.sharepoint.com/sites/ESSAdministration", "table": "a64eb8e5-05a4-49bc-884d-06be180f89c6", "parameters/path": "@variables('ConfidentialMemberFoldername')", "parameters/contentTypeId": "0x0120D52000955FA358847B154D923B040138B3552400F07CC54C1D1EF245BA23C6EE95A11611", "parameters/DynamicProperties/Title": "@{triggerOutputs()?['body/EmployeeNumber']} @{triggerOutputs()?['body/First_x0020_Name']} @{triggerOutputs()?['body/LastName']}", "parameters/DynamicProperties/LastName1": "@triggerOutputs()?['body/LastName']", "parameters/DynamicProperties/FirstName1": "@triggerOutputs()?['body/First_x0020_Name']", "parameters/DynamicProperties/EmployeeID": "@triggerOutputs()?['body/EmployeeNumber']", "parameters/DynamicProperties/DisplayName": "@{triggerOutputs()?['body/First_x0020_Name']} @{triggerOutputs()?['body/LastName']}", "parameters/DynamicProperties/EmployeeStatus": "InActive", "parameters/DynamicProperties/SPSStatus/Value": "Pending", "parameters/DynamicProperties/EmployeeType/Value": "@outputs('Create_item_ESS_Admin_Employee_List__2')?['body/EmployeeType/Value']" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", "connection": "shared_sharepointonline", "operationId": "CreateNewDocumentSet" } }, "metadata": { "operationMetadataId": "20ea638f-ccca-4b30-96de-2996ab779474" } }, "Set_variable_Confidential_Member_File_ID_Get_2": { "type": "SetVariable", "inputs": { "name": "ConfidentialMemberFileIDGetorCreate", "value": "@{outputs('Create_new_document_set')?['body/ID']}" }, "runAfter": { "Create_document_set_folders_2": [ "Succeeded", "TimedOut" ] }, "metadata": { "operationMetadataId": "32f0d385-6650-4dc3-b4c0-3bc54801f358" } } }, "else": { "actions": { "Apply_to_each_3": { "type": "Foreach", "foreach": "@outputs('Get_Confidential_Member_Doc_Set')?['body/value']", "actions": { "Update_Confidential_Member_Files_Previous_Hire": { "type": "OpenApiConnection", "inputs": { "parameters": { "dataset": "https://surreypoliceservices.sharepoint.com/sites/ESSAdministration", "table": "a64eb8e5-05a4-49bc-884d-06be180f89c6", "id": "@items('Apply_to_each_3')?['ID']", "item/Title": "@items('Apply_to_each_3')?['Title']", "item/LastName1": "@triggerOutputs()?['body/LastName']", "item/EmployeeStatus": "InActive", "item/SPSStatus/Value": "Pending", "item/Critical/Value": "No", "item/ProtectionLevel/Value": "Private - Internal and Customer Use Only", "item/Sensitive/Value": "No", "item/DocumentType/Value": "" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", "connection": "shared_sharepointonline", "operationId": "PatchFileItem" } }, "metadata": { "operationMetadataId": "c0b55d56-5ebf-49b1-9193-1d21d9609a25" } }, "Set_variable_Confidential_Member_File_ID_Get": { "type": "SetVariable", "inputs": { "name": "ConfidentialMemberFileIDGetorCreate", "value": "@{outputs('Update_Confidential_Member_Files_Previous_Hire')?['body/ID']}" }, "runAfter": { "Update_Confidential_Member_Files_Previous_Hire": [ "Succeeded" ] }, "metadata": { "operationMetadataId": "32f0d385-6650-4dc3-b4c0-3bc54801f358" } } }, "metadata": { "operationMetadataId": "dd71c266-21b7-45ec-97ae-b028a242a41f" } } } }, "runAfter": { "Get_Confidential_Member_Doc_Set": [ "Succeeded" ] }, "metadata": { "operationMetadataId": "5a6b0cbc-641c-42de-b41f-1ce55b71567f" } } } }, "runAfter": { "Get_item_ESS_Master_Employee_List_Again": [ "Succeeded" ] }, "metadata": { "operationMetadataId": "53be3982-faf4-4dae-9e9e-ba064d201a20" } }

This code represents a sequence of logic for a workflow in a Microsoft Power Automate environment (or another similar system). Here's an explanation of the overall functionality and the specific tasks it performs:

Purpose:

The workflow appears to manage and organize data related to "Confidential Member" document sets in a SharePoint Online site. It checks whether a specific folder or document set exists for a particular user, and based on the result, it either retrieves or creates the necessary data and files.


Key Steps:

  1. Initial Condition Check:
    • The workflow starts by evaluating whether the ConfidentialMemberFolderID exists (i.e., is not null) in the output of a prior step called Get_item_ESS_Master_Employee_List_Again.

IF Block (When ConfidentialMemberFolderID is not null):

If a folder ID (ConfidentialMemberFolderID) exists:

  • An action (Get_Confidential_Member_Files_already_there) retrieves the existing confidential member folder from SharePoint using this ID.
  • It retrieves metadata about the folder or file.
  • The retrieved folder's ID is then stored in a variable called ConfidentialMemberFileIDGetorCreate.

ELSE Block (When ConfidentialMemberFolderID is null):

If the folder ID (ConfidentialMemberFolderID) does not exist:

  1. Search for Existing Document Sets:

    • The workflow searches SharePoint for a document set related to the user's EmployeeNumber.
    • It uses $filter to check if there are document sets marked with the ContentType of "SPSHREmpFileDocSet" that match the given EmployeeNumber.
  2. Check for Results:

    • If no document sets are found:

      • A new folder and document set are created for the user.
      • The creation includes setting predefined metadata (e.g., EmployeeNumber, user's name, EmployeeStatus, etc.).
      • Subfolders are also created within the newly created document set.
      • The newly created folder ID is stored in the variable ConfidentialMemberFileIDGetorCreate.
    • If document sets are already found:

      • The existing document sets are iterated through (Apply_to_each_3).
      • The workflow updates certain metadata of the document sets to reflect the user's details (e.g., LastName, EmployeeStatus, updated Title, etc.).
      • The folder ID of the updated document is stored in the variable ConfidentialMemberFileIDGetorCreate.

Metadata and Connections:

  • This workflow interacts with SharePoint Online via a connection (shared_sharepointonline).
  • Specific actions, such as creating new folders or updating metadata, target a dataset on https://surreypoliceservices.sharepoint.com/sites/ESSAdministration, within a specific table or file structure.

Summary:

This workflow:

  1. Checks for the existence of a confidential member folder for an employee.
  2. If the folder exists, it retrieves its metadata.
  3. If the folder does not exist:
    • It searches for relevant document folders.
    • If none are found, it creates a new document set and associated folders with appropriate properties and metadata.
    • If found, it updates metadata for the existing folders.

The variable ConfidentialMemberFileIDGetorCreate is used across the process to store the ID of the folder or document set that was either retrieved, created, or updated. This variable allows downstream actions in the workflow to reference the appropriate folder.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node