Script to check consecutive numbering sequence

I Have a several  portal rows and the number of rows can vary from 1 to a max of 12.
The user needs to set the Task Sequence manually via a value list numbered 1.2.3.4.5. etc..12.
Task abdc, the first portal row and firt task  is numbered...1
Task bdcf..the second portal row is the second task and is numbered ...2(selected by the user)
Repeat until the total numbered of tasks have been sequenced.
The Sort Portal Records is set to Task Sequence ascending.
This all works well.
If the User in error selects a sequence ranging from 1  to 4 as  1... 2.. 3..5 instead of 1 2 3 4  
I need a script triger to alert the user to the incorect sequence.
I have a script that is based on :
  Go to Portal Row First ,If Task Sequence > 1 ..Show Custom Dialogue
Go to Portal Row Next    If Task Sequence > 2 then show custom dialogue
Again this is ok but the script will end at the last portal row each time which is not what I want.
Is there a shorter way  where the script will evaluate all the sequences entered per portal row and evalauate  if the sequences are in sequence ?
KrisraychrisAsked:
Who is Participating?
 
Will LovingPresidentCommented:
To clarify, are you trying to do my suggested method or your original method? Assuming you are trying to do my suggested method I think you may be doing more than necessary. Take a look at the attached example file which shows a simple setup for assigning sequence numbers to records in a portal. It includes a script attached as a button to each portal record and a relationship that is sorted to first put sequence portal rows first, followed by unassigned (though you could certainly to the opposite and put unassigned at the top by changing the sort order applied to the relationship).

I have not added a renumbering sequence do deal with removing ones out of order but it's not difficult and could easily be added to the script.

Portal Row SequencingClick-to-Sequence.fp7
0
 
Will LovingPresidentCommented:
I'd like to offer an alternate, and i think more elegant, way of going about this - one that I have used on multiple occasions - that completely bypasses the need for the error message. Instead of having the user have to select the Sequence number for each portal record, just have a "next in sequence" area to click on in each portal row. When the user clicks the button area, a script calculates what the next sequence number would be using the Max() function and adding one. So for example:

Max( TaskItems::TaskSequence ) + 1

All the user has to do is select the items in the order that they want them and the next higher sequence number is assigned for them automatically. Clicking a task that is already numbered clears the Sequence number and let's it revert to an unordered state.

If you want to go further you can add a renumbering routine to the "click" script, so that if a user clears the Sequence value - in particular for a task in the middle of the sequence - the script simply runs a loop through all the portal rows that are numbered so far and renumbers them starting with 1. That way if the user clears a Sequence value on any record, the remaining sequence records will be renumbered and the gap eliminated.
0
 
KrisraychrisAuthor Commented:
Hi
Pleasde have alook at the script I am using to get the sequences to increment by one.
It is doing the right things sometimes.On the second click the  highest sequence is plusses a 1.
I have tried go to Record/ Request/Page and this cuases some problems as I may have two sets of sequences open soi I opted for Go to portal row next.
I would appreciate your advice on this.I have changed the filed names of the script for simplicity. The fieedTask Sequence Monday is located in a Table Task  Monday

Go to Layout [ “ Day Monday”  ]
Go to Portal Row [ Select; First ]
If [ IsEmpty( Task Sequence Monday ) or Task Sequence Monday < 1 Task Sequence Monday> 1 ]
Set Field [ TaskSequenceMonday ; 1 ]
End If
Loop
Go to Portal Row [ Select; Next ]
Set Variable [ $TaskSequenceMonday; Value:  TaskSequenceMonday]
 
Set Variable [ $TaskSerquenceplus1; Value:Max(TaskSequenceMonday)+1 ]
 
 
Set Field [ TaskSequenceMonday; $TaskSequenceplus1]
 // Go to Record/Request/Page [ Next; Exit after last ]
Exit Loop If [ PROD ORDER FinishTime Monday::Count Records Total = 10 ]
End Loop
0
 
KrisraychrisAuthor Commented:
Thank you for your sample file.I have used elements of this example and used it fully in another table.Much appreciated !!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.