Hi I am working on app to manage project documents and one part of that is creating a Log of documents.  so the app will have many different projects and each project will have a log of materials. each item entered into the log of materials for a specific project will have a log number which basically identifies the items number on the Log.  so the log numbers would reset for every project. how would I go about creating this Log number?

also here is my data model for the MTR Log Entity. i would imagine that i would have to change this up a little bit

Hi Jay.

I would split this into two parts.

You are using the LogNumber as id and that is not compatible with the Primary Key because Key must be unique and Log Number can be repeated.


First, use an attribute Id with Auto Increment=True as key.

Then, create an attribute LogNumber of type integer to save Log Number.


Find the last used LogNumber and always pick LastUsed+1 as LogNumber.This can be achieved by saving Id in Project table or by doing a Max(LogNumber) filtering by ProjectId.

You can show the LogNumber to users, but Id is for internal use.

Does it make sense to you?

Nuno Reis wrote:

Hi Jay.

I would split this into two parts.

You are using the LogNumber as id and that is not compatible with the Primary Key because Key must be unique and Log Number can be repeated.


First, use an attribute Id with Auto Increment=True as key.

Then, create an attribute LogNumber of type integer to save Log Number.


Find the last used LogNumber and always pick LastUsed+1 as LogNumber.This can be achieved by saving Id in Project table or by doing a Max(LogNumber) filtering by ProjectId.

You can show the LogNumber to users, but Id is for internal use.

Does it make sense to you?

i think so, the excel document doesnt account for the ID number... that got added automatically when i bootstrapped the excel document. so at the moment i do have an autonumber ID for the MTRLog entity and i also have an attribute with the integer type to save the log number.  this is where i get stuck.  would finding the last used log number be dont in an aggregate? and picking last used +1 would be a part of a screen action?

i have been working with outsystems for a little while but this is completely outside of my realm.  I am a welder by trade so any additional help would be greatly appreciated.

Solution

The query would be something like tihs.

You needto create a sserver action the receives the MTRLog info to save and makes this check before.

And then instead of using the default CreateOrUpdate, you need to create your own. You only need to set the number on Create, on Update the number stays the same.

I attached an example. Didn't test it, but the idea is there.


Solution