AnsweredAssumed Answered

How can I loop through a certain foreign key filed in a list view?

Question asked by ScottMcpherson on Jun 18, 2012
Latest reply on Jun 18, 2012 by GuyStevens

Title

How can I loop through a certain foreign key filed in a list view?

Post

Hello, I have a list view of case notes and at the top of that view I have a button to add a new note. When the button is pressed it jumps to the bottom of the list view, the script sets the foreign key for the new note to be added, and the script then goes to the note field so that the user can then begin typing in the new note. The problem I'm having with this approach is that if the user clicks the show all button and then clicks the add new note button, there are several foreign keys in the list view and my script can not accurately set the foreign key to the new note. The way I'm trying to correct that is if the user clicks the add note button the script will:

  1. set a variable called $CaseName to the first foreign key in the list view
  2. set a vaiable $CaseFkCount equal to the total count of all of the foreign keys in the list view
  3. set $Counter variable equal to 1
  4. loop through each record in the list view and if a foreign key does not equal the $CaseName variable then pop up a custom dialog box telling the user that they must be in the context of only one case
  5. each time the loop is iterated, 1 is added to $Counter
  6. if the loop finishes without step 4 equaling true then proceed to set the foreing key for the new note and go to the note field

How Can I make this work?

fmcode.png

Outcomes