Link to home
Start Free TrialLog in
Avatar of Krisraychris
Krisraychris

asked on

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 ?
Avatar of Will Loving
Will Loving
Flag of United States of America image

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.
Avatar of Krisraychris
Krisraychris

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Will Loving
Will Loving
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your sample file.I have used elements of this example and used it fully in another table.Much appreciated !!