6 Replies Latest reply on Apr 8, 2014 11:14 AM by B_1

    script not working for portal entry



      script not working for portal entry


           I have a script that is supposed to take the info. from several fields and put them into other fields on another layout when running the script. There may be multiple tests for each field that are all related to one specimen number. The script is working perfectly when it needs to open a new record and save the data, then display back into the portal on the original layout. However, if there is already one record in the system for a specific specimen number, it will not relate them properly and record the data in the fields into the related table. I will post the script below this to see if anyone has any ideas on why it may not be working correctly. 


        • 1. Re: script not working for portal entry

               The only thing that I can see going wrong is that it is entering the wrong specimen number, causing them to not relate. But after the script enters the wrong specimen number, none of the other fields are being filled out afterwards.

          • 2. Re: script not working for portal entry

                 What relationship have you defined linking Veterinary to Veterinary_Testing?

                 I would guess that you have something like:


                 Veterinary::Vet_Info_pKey = Veterinary_Testing::SomeFieldGoesHere

                 But your script never links the new record in Veterinary_Testing by assigning the value of Vet_info_pkey to a field in the new record. Since no such value is assigned, the new record does not appear to be linked to any record in Veterinary and thus all the set field steps will fail to assign data to the fields in the new record as the new record is not linked to any record from which the set field steps can copy the data.

                 You do copy the value of Vet_Info_pKey in to a variable: $$Vet_SpecNumber, but then your script does nothing more with this variable. Perhaps you have an auto-enter calculation set to use copy the value of this global variable into the match field in Veterinary_Testing, but this is not something that I can tell just from a look at your script. If you do have such an auto-enter calculation, check it very carefully to be sure that the name used in the calculation is spelled exactly the same as the name of the global variable used in your script.

            • 3. Re: script not working for portal entry

                   I attached below the relationship I used between Veterinary and Veterinary Testing. The relationship is between Vet_info_pKey = Vet_Testing_fkey. I also attached below the auto-enter calculation I have used for the Vet_Testing_fkey to equal the global variable ($$Vet_SpecNumber).


                   The relationship and script work when there are no records relating to the fkey. However, once their is a record for a specific fkey, it enters the wrong specimen number in the specimen field and does not fill out any other fields, and also does not add this test information to the portal I have set up. 

              • 4. Re: script not working for portal entry
                /files/d14c85ffa6/autoenter.jpg 1266x975
                • 5. Re: script not working for portal entry

                       The vet_testing_fkey field should not both enter a serial number and also the value of the global variable. Thus, the first thing to do is to remove the auto-entered serial number setting and test to see if that makes a difference in the results that you get.

                       Vet_info_pkey is the field that should be set up as an auto-entered serial number, not the foriegn key field in Vetenary_Testing.

                  • 6. Re: script not working for portal entry

                         I removed the auto enter serial as you suggested and also deselected the unique value field for the f key. The script works perfectly now. Thanks Phil. I was banging my head on the desk over this one.