AnsweredAssumed Answered

Redefining a variable at start of  script loop.

Question asked by jrhutson on Mar 24, 2015
Latest reply on Mar 26, 2015 by philmodjunk

Title

Redefining a variable at start of  script loop.

Post

I am trying to set up a script to facilitate data entry. I have a table of devices and another table of associated events for the devices. Each device will have a series of associated entries in the Device Events table so that you can see the whole history of the device and where it currently is. When new devices are entered I want a user to enter the relevant data from the first device, the script will then set the fields that are common to the batch of devices as variables and allow them to be populate in the next device. That way the user will only have to input the unique information for the next device. The script will loop until they are done entering that batch.

Where I'm running into trouble is with adding an entry to the Device Events table. I'd like the first entry in DeviceEvents for each device to be its entry into the database. To accomplish this part of my Device Entry script will be to run the Device Event script which will go to the DeviceEvent layout, create a new entry and populate the relevant data. The field connecting the Devices table to DeviceEvents is a DeviceID field. If I set a variable from the _DeviceID_pk field, I can then set the __DeviceID_fk field on DeviceEvents from that variable, but users will be inputing batches of devices. If you define the $DeviceID variable at the beginning of a looping script, will it redefine and the beginning of each loop or is there a better way to accomplish this?

I hadn't found any info on whether this will work, so I figured it would be worth asking about. I'll be testing the script tomorrow, but this way if someone else is looking to do something similar there's a post to either guide or warn them.

Outcomes