cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jo2021
Regular Visitor

Power Automate- Approval- get items to restore to previous values once rejected

Hi Experts, 

 

I am in the process of building an automation flow. The flow looks for items that have been modified and then starts an approval process. If approved, the item maintains it's values (after the edit) and shows as being 'approved' in the approval column. 

 

Where I am having difficulty is when an item is rejected. I need the flow to go back into the versioning history and show the item's previous values if an item is rejected. That is to say, if Line X is rejected then restore all information from Line X previous to when edits were made.

 

After intensively looking across the web, I am yet to find a solution that works or incorporates all of the features that I need. I believe the flow is getting stuck at the 'Parse JSON' stage (see below screenshot) but I don't know why. 

 

Does anyone have any experience with building something similar or can advise where I may possibly be going wrong?

 

Thanks in advance, 

 

J

 

Screen Shot 2021-09-22 at 12.00.54.png

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @jo2021,

 

Can you expand that Parse Json action in the history of the flow that failed to see what the actual error says and share a screenshot of it?

 

I would also be interested in the configuration of the Send an HTTP request to SharePoint action and the schema of the Parse JSON action. Can you share that as well?

View solution in original post

8 REPLIES 8
Expiscornovus
Super User
Super User

Hi @jo2021,

 

Can you expand that Parse Json action in the history of the flow that failed to see what the actual error says and share a screenshot of it?

 

I would also be interested in the configuration of the Send an HTTP request to SharePoint action and the schema of the Parse JSON action. Can you share that as well?

View solution in original post

Hi,

 

Thanks for your response. Please see screenshots below:

 

Screen Shot 2021-09-22 at 13.53.50.pngScreen Shot 2021-09-22 at 13.54.26.png

 

jo2021
Regular Visitor

Expiscornovus
Super User
Super User

Hi @jo2021,

 

It looks like it can't validate the response of the Send an HTTP request action based on the schema you are using in your parse json action.

 

I have just generated a schema myself for the same kind of Get request. Can you try that schema instead?

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "results": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "__metadata": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "uri": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    }
                                }
                            },
                            "CreatedBy": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Fields": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "FileVersion": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Created": {
                                "type": "string"
                            },
                            "IsCurrentVersion": {
                                "type": "boolean"
                            },
                            "VersionId": {
                                "type": "integer"
                            },
                            "VersionLabel": {
                                "type": "string"
                            },
                            "ContentTypeId": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "StringValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "OData__x005f_ModerationComments": {},
                            "FileLeafRef": {
                                "type": "string"
                            },
                            "Modified_x005f_x0020_x005f_By": {
                                "type": "string"
                            },
                            "Created_x005f_x0020_x005f_By": {
                                "type": "string"
                            },
                            "File_x005f_x0020_x005f_Type": {
                                "type": "string"
                            },
                            "HTML_x005f_x0020_x005f_File_x005f_x0020_x005f_Type": {},
                            "OData__x005f_SourceUrl": {},
                            "OData__x005f_SharedFileIndex": {},
                            "ComplianceAssetId": {},
                            "Title": {},
                            "TemplateUrl": {},
                            "xd_x005f_ProgID": {},
                            "xd_x005f_Signature": {},
                            "OData__x005f_ShortcutUrl": {},
                            "OData__x005f_ShortcutSiteId": {},
                            "OData__x005f_ShortcutWebId": {},
                            "OData__x005f_ShortcutUniqueId": {},
                            "OData__x005f_ExtendedDescription": {},
                            "MediaServiceMetadata": {
                                "type": "string"
                            },
                            "MediaServiceFastMetadata": {
                                "type": "string"
                            },
                            "SharedWithUsers": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "results": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "LookupId": {
                                                    "type": "integer"
                                                },
                                                "LookupValue": {
                                                    "type": "string"
                                                },
                                                "Email": {
                                                    "type": "string"
                                                }
                                            },
                                            "required": [
                                                "LookupId",
                                                "LookupValue",
                                                "Email"
                                            ]
                                        }
                                    }
                                }
                            },
                            "SharedWithDetails": {
                                "type": "string"
                            },
                            "Shipto": {},
                            "Building": {},
                            "GroupNavigation3": {},
                            "TriggerFlowInfo": {},
                            "MediaServiceAutoTags": {},
                            "MediaServiceOCR": {},
                            "MediaServiceGenerationTime": {},
                            "MediaServiceEventHashCode": {},
                            "ID": {
                                "type": "integer"
                            },
                            "Author": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    },
                                    "Email": {
                                        "type": "string"
                                    }
                                }
                            },
                            "Modified": {
                                "type": "string"
                            },
                            "Editor": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    },
                                    "Email": {
                                        "type": "string"
                                    }
                                }
                            },
                            "OData__x005f_HasCopyDestinations": {},
                            "OData__x005f_CopySource": {},
                            "OData__x005f_ModerationStatus": {
                                "type": "integer"
                            },
                            "FileRef": {
                                "type": "string"
                            },
                            "FileDirRef": {
                                "type": "string"
                            },
                            "Last_x005f_x0020_x005f_Modified": {
                                "type": "string"
                            },
                            "Created_x005f_x0020_x005f_Date": {
                                "type": "string"
                            },
                            "File_x005f_x0020_x005f_Size": {
                                "type": "string"
                            },
                            "FSObjType": {
                                "type": "string"
                            },
                            "SortBehavior": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "CheckedOutUserId": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {}
                                }
                            },
                            "IsCheckedoutToLocal": {
                                "type": "string"
                            },
                            "CheckoutUser": {},
                            "UniqueId": {
                                "type": "string"
                            },
                            "SyncClientId": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {}
                                }
                            },
                            "ProgId": {
                                "type": "string"
                            },
                            "ScopeId": {
                                "type": "string"
                            },
                            "VirusStatus": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "CheckedOutTitle": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {}
                                }
                            },
                            "OData__x005f_CheckinComment": {
                                "type": "string"
                            },
                            "MetaInfo": {
                                "type": "string"
                            },
                            "OData__x005f_Level": {
                                "type": "integer"
                            },
                            "OData__x005f_IsCurrentVersion": {
                                "type": "boolean"
                            },
                            "ItemChildCount": {
                                "type": "string"
                            },
                            "FolderChildCount": {
                                "type": "string"
                            },
                            "Restricted": {
                                "type": "string"
                            },
                            "OriginatorId": {
                                "type": "string"
                            },
                            "NoExecute": {
                                "type": "string"
                            },
                            "ContentVersion": {
                                "type": "string"
                            },
                            "OData__x005f_ComplianceFlags": {
                                "type": "string"
                            },
                            "OData__x005f_ComplianceTag": {
                                "type": "string"
                            },
                            "OData__x005f_ComplianceTagWrittenTime": {
                                "type": "string"
                            },
                            "OData__x005f_ComplianceTagUserId": {
                                "type": "string"
                            },
                            "BSN": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "OData__x005f_ListSchemaVersion": {
                                "type": "string"
                            },
                            "OData__x005f_Dirty": {
                                "type": "string"
                            },
                            "OData__x005f_Parsable": {
                                "type": "string"
                            },
                            "OData__x005f_StubFile": {
                                "type": "string"
                            },
                            "OData__x005f_HasEncryptedContent": {
                                "type": "string"
                            },
                            "AccessPolicy": {
                                "type": "string"
                            },
                            "OData__x005f_VirusStatus": {
                                "type": "string"
                            },
                            "OData__x005f_VirusVendorID": {
                                "type": "string"
                            },
                            "OData__x005f_VirusInfo": {
                                "type": "string"
                            },
                            "OData__x005f_CommentFlags": {
                                "type": "string"
                            },
                            "OData__x005f_CommentCount": {
                                "type": "string"
                            },
                            "OData__x005f_LikeCount": {
                                "type": "string"
                            },
                            "OData__x005f_RmsTemplateId": {
                                "type": "string"
                            },
                            "OData__x005f_IpLabelId": {
                                "type": "string"
                            },
                            "OData__x005f_DisplayName": {
                                "type": "string"
                            },
                            "OData__x005f_IpLabelAssignmentMethod": {
                                "type": "string"
                            },
                            "A2ODMountCount": {
                                "type": "string"
                            },
                            "OData__x005f_ExpirationDate": {
                                "type": "string"
                            },
                            "AppAuthor": {},
                            "AppEditor": {},
                            "SMTotalSize": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "SMLastModifiedDate": {
                                "type": "string"
                            },
                            "SMTotalFileStreamSize": {
                                "type": "string"
                            },
                            "SMTotalFileCount": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {
                                        "type": "string"
                                    }
                                }
                            },
                            "owshiddenversion": {
                                "type": "integer"
                            },
                            "OData__x005f_UIVersion": {
                                "type": "integer"
                            },
                            "OData__x005f_UIVersionString": {
                                "type": "string"
                            },
                            "InstanceID": {},
                            "Order": {
                                "type": "integer"
                            },
                            "GUID": {
                                "type": "string"
                            },
                            "WorkflowVersion": {
                                "type": "integer"
                            },
                            "WorkflowInstanceID": {},
                            "ParentVersionString": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {}
                                }
                            },
                            "ParentLeafName": {
                                "type": "object",
                                "properties": {
                                    "__metadata": {
                                        "type": "object",
                                        "properties": {
                                            "type": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "LookupId": {
                                        "type": "integer"
                                    },
                                    "LookupValue": {}
                                }
                            },
                            "DocConcurrencyNumber": {
                                "type": "string"
                            },
                            "ParentUniqueId": {
                                "type": "string"
                            },
                            "StreamHash": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "__metadata",
                            "CreatedBy",
                            "Fields",
                            "FileVersion",
                            "Created",
                            "IsCurrentVersion",
                            "VersionId",
                            "VersionLabel",
                            "ContentTypeId",
                            "OData__x005f_ModerationComments",
                            "FileLeafRef",
                            "Modified_x005f_x0020_x005f_By",
                            "Created_x005f_x0020_x005f_By",
                            "File_x005f_x0020_x005f_Type",
                            "HTML_x005f_x0020_x005f_File_x005f_x0020_x005f_Type",
                            "OData__x005f_SourceUrl",
                            "OData__x005f_SharedFileIndex",
                            "ComplianceAssetId",
                            "Title",
                            "TemplateUrl",
                            "xd_x005f_ProgID",
                            "xd_x005f_Signature",
                            "OData__x005f_ShortcutUrl",
                            "OData__x005f_ShortcutSiteId",
                            "OData__x005f_ShortcutWebId",
                            "OData__x005f_ShortcutUniqueId",
                            "OData__x005f_ExtendedDescription",
                            "MediaServiceMetadata",
                            "MediaServiceFastMetadata",
                            "SharedWithUsers",
                            "SharedWithDetails",
                            "Shipto",
                            "Building",
                            "GroupNavigation3",
                            "TriggerFlowInfo",
                            "MediaServiceAutoTags",
                            "MediaServiceOCR",
                            "MediaServiceGenerationTime",
                            "MediaServiceEventHashCode",
                            "ID",
                            "Author",
                            "Modified",
                            "Editor",
                            "OData__x005f_HasCopyDestinations",
                            "OData__x005f_CopySource",
                            "OData__x005f_ModerationStatus",
                            "FileRef",
                            "FileDirRef",
                            "Last_x005f_x0020_x005f_Modified",
                            "Created_x005f_x0020_x005f_Date",
                            "File_x005f_x0020_x005f_Size",
                            "FSObjType",
                            "SortBehavior",
                            "CheckedOutUserId",
                            "IsCheckedoutToLocal",
                            "CheckoutUser",
                            "UniqueId",
                            "SyncClientId",
                            "ProgId",
                            "ScopeId",
                            "VirusStatus",
                            "CheckedOutTitle",
                            "OData__x005f_CheckinComment",
                            "MetaInfo",
                            "OData__x005f_Level",
                            "OData__x005f_IsCurrentVersion",
                            "ItemChildCount",
                            "FolderChildCount",
                            "Restricted",
                            "OriginatorId",
                            "NoExecute",
                            "ContentVersion",
                            "OData__x005f_ComplianceFlags",
                            "OData__x005f_ComplianceTag",
                            "OData__x005f_ComplianceTagWrittenTime",
                            "OData__x005f_ComplianceTagUserId",
                            "BSN",
                            "OData__x005f_ListSchemaVersion",
                            "OData__x005f_Dirty",
                            "OData__x005f_Parsable",
                            "OData__x005f_StubFile",
                            "OData__x005f_HasEncryptedContent",
                            "AccessPolicy",
                            "OData__x005f_VirusStatus",
                            "OData__x005f_VirusVendorID",
                            "OData__x005f_VirusInfo",
                            "OData__x005f_CommentFlags",
                            "OData__x005f_CommentCount",
                            "OData__x005f_LikeCount",
                            "OData__x005f_RmsTemplateId",
                            "OData__x005f_IpLabelId",
                            "OData__x005f_DisplayName",
                            "OData__x005f_IpLabelAssignmentMethod",
                            "A2ODMountCount",
                            "OData__x005f_ExpirationDate",
                            "AppAuthor",
                            "AppEditor",
                            "SMTotalSize",
                            "SMLastModifiedDate",
                            "SMTotalFileStreamSize",
                            "SMTotalFileCount",
                            "owshiddenversion",
                            "OData__x005f_UIVersion",
                            "OData__x005f_UIVersionString",
                            "InstanceID",
                            "Order",
                            "GUID",
                            "WorkflowVersion",
                            "WorkflowInstanceID",
                            "ParentVersionString",
                            "ParentLeafName",
                            "DocConcurrencyNumber",
                            "ParentUniqueId",
                            "StreamHash"
                        ]
                    }
                }
            }
        }
    }
}

Hi @Expiscornovus

 

Thanks! That worked and the 'Parse JSON' stage was completed successfully. However the flow has now failed at the next stage. See screenshots below:

 

Thanks,

 

JSS1.jpgSS2.JPG

Expiscornovus
Super User
Super User

Hi @jo2021,

 

Body is not an array or a collection. So, you don't need the apply to each 2 loop anymore. 

 

You can directly start with the Apply to each 3 action to loop to the results property (which is a array or collection).

 

loopthroughresults.png

@Expiscornovus 

 

Seems to now not pick up the fields from the Parse JSON... Just comes up with 'type'. See below:

 

SS3.png

Expiscornovus
Super User
Super User

Hi @jo2021,

 

We need to update the Parse Json schema to use your custom fields. Forgot about that in my last reply 😅

 

1. Go to one of your last flow runs in the history.

 

2. Select the whole body in the response section. Copy it.

 

generatenewschema.png

 

3. Go to Parse Json action. Paste it in the insert a sample JSON payload and click done. Now you should have a schema with your custom fields. 

 

pastesample.png

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,610)