Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Using Variables in scripts


Recommended Posts

I'm trying to set variables and then use them within scripts and I'm having difficulty with them. The variables are not setting into the fields that I have in the script (using the Set Field step) Some of the layouts/tables that I switch too are not related to the original layout/tables that I retained the scriptparameter from. I guess my question is, can variables be passed to fields that are not related to the table that it was originally set from.


It's possible that I'm using the wrong calculation to Set the field, so here is an example:


Button has "Optional Scriptparameter" to collect the StudentID.


The script's first step is:


Set Variable [$$studentID; Get(Scriptparameter)]


Now I want to be able to use this variable throughout this script as well as subsequent scripts to follow to pass along the Student ID.


This may be too confusing to explain, but I thought I'd give it a shot.



Link to comment
Share on other sites

Oughta work, generically speaking.


Easy temporary debugging:


Show Custom Dialog ["Original Field Value", Table::Student ID, "OK"]

Show Custom Dialog ["Script Parameter", Get(ScriptParameter), "OK"]

Set Variable [$$StudentID, Get(ScriptParameter)]

Show Custom Dialog ["Variable", $$StudentID, "OK"]


If the first custom dialog comes up blank, that means Student ID cannot be assessed from the vantage point the script is being run from, which explains your problem. If the first comes up fine but the second is blank, something is amiss in the setting of script parameter. If the first two are fine but the third is blank, the variable is not being properly set for some reason.


That's also in decreasing order of likelihood, or so says my hunch.

Link to comment
Share on other sites

Keep in mind that the scope of variables is limited to the file they are defined in. If you have sub-scripts in other files, you'll need to pass the values in a script parameter or by using a global field.

Link to comment
Share on other sites

Thanks, I'll give it a try. I was actually able to get around what I wanted to do by setting (unfortunately) a few global fields in the tables. It all seems to be working and after all this time, not sure I want to go back. But I will try the debugging example.

Link to comment
Share on other sites

Can I use the variable from Set Variable in a Close Window script step? This is done in the same script, same file. Not getting the results I want. Maybe that window has to be active???


Set Variable [$windowname; Value:Get(WindowName)]

Close Window [$windowname]

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Terms of Use