Creating Versions, Conditional blank or pre-filled edit-screens 

Creating Versions, Conditional blank or pre-filled edit-screens 


Hi all,


I have some challenges I really need some help with.


I'm developing a ContractManagement app. For this I created an entity 'Contracts' and an entity 'ContractVersions'.


The general idea is that the user should be able to, for instance, renew a contract by editing a version, and this new version is stored as a version with a versionnumber 1 higher than the previous related to the same Contract. Moreover a new (first) version related to a new contract should automatically be assigned versionnumber 1.


I have managed to use an assign to create a versionnumber=versionnumber + 1.




After creating a new Contract, the new first version of this contract is being assigned a versionnumber 1 higher than the highest version of an existing Contract, not being the Contract for which I am creating a first version. To clarify:


Creating a Contract and 2 versions:


Contract[Id=1] → Version 1, Version 2


This is ok but when creating a new Contract this happens:


New Contract:


Contract[Id=2] → Version 3


Ofcourse I want it to be Version 1 because it's ContractVersion 1 under Contract[Id=2].


How can I manage to create a versionnumber +1 only fetched from the specific contractversions under this specific contract[Id]? Do I need to create an advanced query to fetch the highest versionnumber related to this contract[Id], and subsequently assign a versionnumber OutcomeAdvancedQuery+1? Or is there some simple solution to this problem/challenge (maybe some refresh action)?





For an update I want the user to edit the contents of the highest contractversion related to a specific Contract[Id]. After this edit the Contractversion is not updated but a new ContractVersion with a versionnumber + 1 is created. Aside from the problem described above, this seems to work.


However, I also want the user to create a first version for a contract in a completely empty edit-screen. However, if I create a first version of a Contract I get an edit-screen/form pre-filled with data from the latest created version (not necessarily related to the same contract).


How can I set a condition to present an empty edit-screen/form? And, related to the first problem, how do I set the pre-filled data to be from the latest ContractVersion related to the specific contract I'm editing?





To fetch the latest ContractVersion of a Contract for edit, I have to order the list by VersionNumber Descending (DESC). I managed to do this by using an 'order by'. If I test the query the highest VersionNumber is the first record in the list. Also the edit screen is pre-filled with data from this record with the highest VersionNumber: So far so good.


However, the table showing Versions still orders the records Ascending! Any ideas about the cause of this behaviour?


For people kind enough to have a look I have created a small espace to show these problems (see attachment).

Any hints, solutions and easy solutions for my challenges? I would really appreciate it!


Rienk Eisma



Hi Rienk

Simple query with Contract=Id, Order by
ContractVersion desc. And on the Max Records property set it to 1.

Not sure if half the problem is not caused by your browser auto-fill options. Try to turn form auto-fill off in the options. If that is the problem google how to force it to be disabled it on a web-page side.

Second part of that problem, filling the form with the previous values. You can do that when you are rendering the page. If you set the values of the record associated with the edit record on the screen preparation they will be set on the user side when the page renders.

Your Order by condition in the preparation is till saying ASC:
List_SortColumn_GetOrderBy(Contract_ContractversionTable.Id, "{CONTRACTVERSION}.[VersionNumber] ASC")
On the RefreshContractversionTable it looks good:
List_SortColumn_GetOrderBy(Contract_ContractversionTable.Id, "{CONTRACTVERSION}.[VersionNumber] DESC")

Also the Contract_Show is sorting by [Signed]

João Rosado
Hi João,

It works perfectly now, thank you very much.

Because I could not assign a 1 to an empty versionnumber edit screen, I deleted the edit row for versionnumber. Now a first version is assigned 1 by setting the null value to 1. Every version following is assigned +1 so it all works perfectly now (also the order by thanks for pointing to the cause).

Just for readers facing the same problem a short summary:

The main problem was that I didn't set ContractId (Parent-entity) as a parameter. After setting this parameter for the query I was able to insert the condition 
João suggested (Contract.Id=ContractId). This results in a correct assignment of versions (Child-entity) to a specific contract.


Rienk Eisma