Using a functional global variable in DAI

Can anyone tell me how I use a global variable which was set by a functional script in DAI to decide different paths in the model?

I have set a global variable which is not only used by other functional scripts, but I want to use in a model to determine which route to take. I know and have used variables from DAI to a functional script, but cannot figure out how to do it the other way round.

Thank you in advance.

I use preconditions to do stuff like that. I set my global in DAI, then have one of my actions leading up to the split set the variable to a value, then have at least two actions at the splitting point. One action has at least one “Precondition for This Action to Execute” that should equal what the leading up action variable is (or could be). Then draw the “Connections from Action” line off on it’s own separate path.

The “Path Variable Set Here” action sets the variable in my example, but you will probably want some more complex snippet on that action setting it instead of the Action itself. Depends what you are doing. And of course the variable doesn’t have to get set here, just somewhere before the path decision gets made.

I don’t usually put any snippets on my precondition actions. Maybe some logging.

Hi @LoganC, If I understand you correctly, this approach won’t help me as my testing is data driven - meaning that I do not know what row in an excel spreadsheet will be picked until some functional code is executed.

For me, this means that only functional snippets will truly know what route to be taken but the DAI model does not. This is why I need to push the variable to DAI to get the model to choose the correct path.

Your solution is exactly the way I was instructed, but I am trying not to have variables in the model itself and to use spreadsheets as the data which will drive the decision making process because the data is constantly changing and it’s impossible to train everyone to use/create/update the model.

Thank you anyhow for your reply.

I read data from Excel frequently and use that data for decision making. For me, the common scenario is reading in information about patients. A common list of columns would include Medical Record Number (MRN), FirstName, LastName, Gender.

//Creates a database connection to the Excel file *datafilename* in the Suite/Resources folder
set global myConnectionString to (type:"excel", file:ResourcePath(datafilename), writable: Yes) -- set the specified variable, myConnectionString, to store the contents of the referenced Excel file

//Set global CurrentPatient to a property list containing all values for the patient in Excel with "123456" in the MRN column
set global CurrentPatient to the record of global myConnectionString where MRN is "123456"

//Makes a decision based on the gender of the patient
If global CurrentPatient.Gender = "F" then
  Run "CheckForPossiblePregnancy"
Else
  --Do nothing
End If

Hope this helps,
Dave