Jump to content

dynamic ordered value lists


This topic is 3960 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need some theoretical and logistical help:

 

My solution is a checkout system which involves penalties when an item is late. The problem is that two parts of the campus (luckily each running their own solution) want to impose penalties differently.

 

My goal was to create a utility table so that I could create one solution that would potentially work for both parts of the campus.

 

My idea: I created one value list that has 12 different penalties (from 1 day to 1 year). I put these on a utility table so that the different solutions could choose which penalties they wanted to implement via checkbox.

 

I then created another value list based on those choices. This seems to work fine.

 

My issue: How to I create a script that will go to the next value ( for example, campus A wants to go from warning to one year block and campus B want to go from warning to 1 week suspension). I was hoping to create one script that would go from value list item one to value list item two, etc. regardless of which items were in the list.

 

 

Link to comment
Share on other sites

Create an X relationship between your table and YourUtilityTable if there is not one already.  Create a global field YourTable::Penalties = List(YourUtilityTable::PenaltyName).

 

Script:

 

If[ not IsEmpty(YourPenaltyField)]

Set Variable[ $valcount; ValueCount(Penalties)]
Loop
   Exit Loop If [ GetValue(Penalties; $ctr) = YourPenaltyField]
   Set Variable [$ctr; $ctr + 1]
   Exit Loop If [ $ctr > $valcount]
End Loop
If [ $ctr = $valcount]
   Show Custom Dialog [ "Maximum Penalty Imposed"]
Else
   Set Field [YourPenaltyField; GetValue(Penalties; $ctr + 1)
End If
End If 
 
 
 
 

 

Link to comment
Share on other sites

doughemi,

 

Thanks for the help and (with your patience) I will understand the script.

 

 

Loop

   Exit Loop If [ GetValue(Penalties; $ctr) = YourPenaltyField]
   Set Variable [$ctr; $ctr + 1]
   Exit Loop If [ $ctr > $valcount]
End Loop

 

Can you help me understand this part of the script - specifically this area. (not the loop part, but the variable $ctr)

Link to comment
Share on other sites

$ctr is simply a counter.

 

You need to progress through each value in the list to determine which is your current penalty.

 

$ctr starts at 1, so the first Exit Loop If step looks at the first value in the list.  If that is the current penalty in YourPenaltyField, then the loop is exited.

If not, $ctr is incremented to 2.  The second Exit Loop If step checks to see if that value is greater than the number of values in the list ($valcount).  If so, we don't want to look any more.

If you haven't exited the loop, go back and check if the current penalty is the second one in the list.  And so on until either you run out of values or you find one that matches.

 

Once you are out of the loop, you set YourPenaltyField to the next value in the list, which is the one after the current value; i.e  GetValue(Penalties;  $ctr + 1).

Link to comment
Share on other sites

OK, I think I have this one working. However, I think I need your help to backtrack and make sure I have my Value Lists correctly setup. With the example above, I have it working, but realized I was not using a global field in the utility table... so:

 

In another example, I want to have a list in the setup layout that will has all potential timeframes to checkout assets ( 1 day, 1 week, 2 weeks, 1 month etc.) The 'person in charge' would be able to check these boxes so that when the end user goes to the assets layout, it would only show these choices as radio buttons. Then each asset could have their unique time period.

 

I was able to get this to work by creating a value list with all potential timeframes as custom values. I then created a timeframes_field in my Utility table that accesses these values as a checkbox set. My next step is to create a field in my assets table that will display only checked values. I did this by creating another value list using values from timeframes_field from my Utility (items checked). This works, but if I try to make the timeframes_field global, it returns the error stating that the field could not be indexed, so it won't work.

 

Should I leave it the way I have it? Or did I miss a step (or overcomplicate) One person suggested a calculation field in my utltity table instead - not sure what they mean. 

Link to comment
Share on other sites

Yes, that does help - However, is there a benefit to having asset durations in a separate table? In my case (as above) I created a text field in my Utilities table (could not make it global though) and in that layout I created one record (and checkbox set) and attached a value list with custom values instead of accessing records from a table - is that a bad way to go? I then created a second value list using values from this utility field and attached it to my asset timeline choice field (as radio buttons)  

 

All assets will have the same valid durations (instead of having different choices for each item) and the user will choose one of them for each asset.

Link to comment
Share on other sites

 attached a value list with custom values instead of accessing records from a table - is that a bad way to go?

Not really, as long as you are sure that the durations will never, ever change, or that you will be around to make the changes in the database structure if they do.

 

Otherwise, adding or deleting records is easy for anyone to do, as long as those actions are properly scripted.

 

All assets will have the same valid durations (instead of having different choices for each item) and the user will choose one of them for each asset.

 

 

I guess I was still thinking of your original scenario, where different schools had different criteria.

Link to comment
Share on other sites

This topic is 3960 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.