Previous Document Version vs Newest Doc verions with Fusion? | Community
Skip to main content
Level 2
April 16, 2024
Question

Previous Document Version vs Newest Doc verions with Fusion?

  • April 16, 2024
  • 2 replies
  • 666 views

Hi all,

 

Pretty new to fusion and trying to work out a new problem.

 

I think I am close but can't get it to work exactly.

I am looking to find the previous version of a document with Fusion, if the new version is greater than the previous version then run the scenario.

 

I have a different scenario that runs based of a watch event for new and update but was wondering if this alt route is possible?

 

I was able to get all the versions using a read related module on the document versions.

How would I filter for the last previous so I can assign it to a variable?

I tired something like this but I can't get it to work: Bundle order position = Total number of Bundles - 1

 

 

 

Alternatively if there is a better way to pull the last version what would be the best module to use?

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

lgaertner
Level 9
April 17, 2024

Hello Daniel,

 

as far as I know there is no build in function to get the most recent entry, but I think you can do the following:

 

1. Use the Array aggregator module to put your search results into an array

2. Combine the sort() and the map() functions to get the document versions in descending order

{{sort(map(229.array; "version"); "desc")}}

 3. Now you know, that the previous version always has the position 2 in your array and from there you can go on

 

To assign the version on position 1 (your previous version) to a variable you can use

Perhaps there is an easier way to solve your problem, but this is, what came into my mind at first.

{{get(232.testvar123; 2)}}

 

Regards

Lars

Level 2
April 25, 2024

@danielsi1 ,

I have done this by adding 'Watch Event' on Document, compare oldState.currentVersion with newState.currentVersion  , run scenario if both are not equal.