2 Replies Latest reply on Feb 12, 2013 12:41 PM by NathanVeitch

    Having trouble with a find script

    NathanVeitch

      Title

      Having trouble with a find script

      Post

      Hi All,

      I need to find out what I am doing wrong in my search script as I have had this problem before and now I did a work around to get it working, but I'm sure there is something I am doing wrong. 

      The scenario is this. I have 2 tables, one Project and one Items. In Project I have a value called CSNumber and in my layout for Project I have a portal to Items. I am trying to use the CSNumber as a find option. The CSNumber could be seen as a type of mock primary key for the record. Now in the CSNumber field on the Project layout, I have set it as a drop-down list and the value list is the CSNumber field. So when the drop down list is accessed you see a list of all the CSNumbers. This is working nicely.

      Now here is the thing, if I try and use that value in CSNumber for the search option, it comes back with 2 records instead of one. On inspection I found that every time I was selecting the value from the drop down list, it would update the field to that number, and then run the find option. For example, if I had numbers 1 - 5 and I was on number 2, then using the drop down list I pressed on value 4 to search for, I would end up with numbers 1, 3, 4, 4 and 5, it would change the value from 2 to 4. 

      I saw this when I was going over script debugger and data viewer. The script is set to run OnObjectModify, and while stepping through the script, that was when I saw the value change before the find portion ran. I tried changing it between modify, validate and keystroke, but it seems that the value changes before the script is even activated. 

      I have been able to do a work around for now, where I copy the value off when the object is entered and then copy it back just after the value I want to search for has been saved. So as far as the user is concerned it is working. I was just wondering where I am going wrong in the script that the value changes before I even get time to run the script. 

      I'm sure it is something simple :$