AnsweredAssumed Answered

Performing a script based on variable input into a field

Question asked by atrinabrill on Feb 28, 2018
Latest reply on Feb 28, 2018 by jfletch

Hi there,

 

I would like to perform a script X number of times based on a number that the user inputs into a layout. I imagine that it's a script parameter, but I'm not sure what the calculation should look like. Or perhaps I should use a loop? I'm uncertain.

 

On the "Add New Grant" layout for Grants table, users input NumYrs (Number of grant years). I have a button on this layout for "save" that commits the records and creates new records in a related table "AcctYr" that copies over some information that users input into the Grants table via the Add New Grant layout so that users don't have to enter it again (e.g. Grant::__pkGrantID, Project::__pkProjectID, Account::__pkAcctID) and the new record for the AcctYr table already has these values included in the new records.

 

Users should be able to see a summary of "completeness" of the records related to the AcctYr:_fkGrantID (populated from Grant::__pkGrantID), and to be able to easily tell how many of the years have been entered and how many need to be completed. I would like to automatically create the number of records with the same GrantID, ProjectID, and AcctID that corresponds to the number provided in Grant:: NumYrs. For example, if the user input "5" as the number of years, I would like to automatically create 5 records that have AcctYr::_fkGrantID, _fkProjectID, and _fkAcctID all the same with a new serial value for AcctYr::__pkAcctYrID.

 

Additionally, I would like each of these records to have a serial value in AcctYr::Year starting at 1, such that each record will already be designated to that particular Account Year. For example, for the first record, the GrantID, ProjectID, and AcctID will be the same but the AcctYr::Year field will be set to 1. For the second record, everything will be the same except the AcctYr::Year field will be set to 2 and so on.

 

Thank you in advance for your help!

Outcomes