Slate - set multiple variables via javascript? - palantir-foundry

How can i set multiple variables via JavaScript in Slate?
So, can i set a slate variable also via JavaScript, by running a JavaScript if a button event was done?
I want to avoid 10 events for each variable...

Related

How can I set a variable in my workshop module via URL?

I currently have a workshop module that allows users to view a set of objects and then filter them according to a filter widget.
I would like my users to be able to set which filters are applied via URL such that they can quickly apply their default filters.
How can I achieve this?
Create a variable for each filter you would like the user to be able to apply via URL.
Promote the variable so that it can be update via the URL.
Update the filter output to use the variables you created above.
In addition to using the promoted variables described in the answer above, specifically for the case of saving and re-using Filter state, you can enable the State Saving feature for users of your app, which allows them to snapshot and save specific application state as a separate Foundry resource. You can then share the link or bookmark or re-open from a folder without worrying about the "wiring" of variables and URL parameters.

Is that possible to create a custom input widget in Foundry Slate?

I know how to use input widget in Slate but I have a use case where I need to create several inputs from an array. Maybe one, maybe more, let's say around 10 or 15. Is that possible to create a input and to catch the user entry just by using an HTML widget.
One other way to say shoud be: I would like to have a table of 1 to 15 rows with one column dedicated to an input area. Number of row depend of the source data, so I want that the input is created dynamically. Is it possible in foundry-slate ?
Best regards
You can't do this in a plain HTML widget - the dependency graph can't read state from arbitrary HTML input elements.
There are a couple other options here; the one that most directly works they way you would like it to in your question, would be to use the Code Sandbox widget, which effectively let's you build your own widget and wire it up to the Slate dependency graph for interaction with the rest of the app. You can use a 3rd-party library, assuming you have the license, to do something more advanced (you can search your Foundry instance for some examples in the Slate Reference Examples) or simply use HTML and Javascript to build the widget as you would in normal web development as you have access to the DOM and JQuery when working in the Sandbox.
Slightly more in-line with how Slate might expect you to build this functionality, you can use a single input widget, but toggle what you do with the associated input based on other state, for example what row the user has selected. This, in combination with a button that stores the input into a Variable with a click event, can be used to let users build up a "bag" of edits, that you can then apply with Actions (or you can apply them immediately - all depends on the workflow). You'll find some examples of that pattern in the "Events" folder in the Slate Reference Examples.
Thinking a bit more expansively, if you model your data in the ontology, you can set up an editable table pattern in Workshop and have a quite straightforward experience once you have the right Action and Object Type configuration. You'll find the documentation on this on your Foundry instance at https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#inline-edits-or-cell-level-writeback and an example in the Flight Alert Inbox example application.

In Foundry Workshop, is it possible to reset a scenario when a user navigates away from a Workshop tab?

I've created a scenario in Foundry Workshop, and would like to set it up so that it resets whenever a user changes their active Workshop tab. Is it possible to accomplish this within scenario variables?
If the scenario array variable is produced from a scenario object set, then changing the object set should reset it. See the relevant documentation for this at https://www.palantir.com/docs/foundry/workshop/scenarios-save/ .
If you have a single dynamic scenario that you'd like to reset, then you can use the "Reset variable" event to reset it to its default value.

Can I use global variable instead of passing parameters?

I have a Javascript project which one of its script receive a parameter. Instead of passing this parameters throughout function chains can I declare it one as global and have other functions referring to it instead?
What if there are many scripts in the project? Can these access this global variable somehow? I need to have it persistent to the duration of the execution only.
Note that this project can be called by various users and at once. As it is sometimes invoked through a webapp I am not sure User cache would be appropriate.
Thanks!
Don't use Global variables for Apps Script Services. For example:
var SS_SERVICE = SpreadsheetApp;
Recently this started causing an error message. If this changes, please edit the answer at that time.
Also, if you do not use the var keyword to define a variable, then it automatically gets put into the global scope. So, if by mistake, you fail to put var in front of your variable, then the code still runs and may work, but you may be unaware of what is really happening with your code. If you defined and used another variable with the same name in a different function, and also mistakenly made that variable a global, and one function called the other function, then there could be a conflict with the variable values.
All Apps Script .gs files can access all other .gs script files. There doesn't need to be any link between script files, or inclusion into other script files. You can call a function from another script file, as long as it's in the same project.
And global variables defined in one file are accessible to other files.
You don't want to use public Cache for information specific to that user. But there is private Cache. And Cache expires, so unless it's for something like timing how long a user is logged in, you might not want to use it.
If you have lots of code, and create functions for reasons of orderly structure and access to multiple other functions, then passing data might be undesirable. So, yes, you can use global variables. It's considered "Bad Practice" by some to use global variables, but then we are getting into personal opinion.

Call an embedded macro from VBA in access

I have a macro assigned to the onClick event of a button in a form. How can I call this macro programmatically?
I tried
btnName_Click
But this does not work since there is no function called btnName_Click() ... obviously :)
I can access the onClick Member via Me.btnNewRecord.OnClick but don't see a way to run the macro.
After extensive searching, I do not believe it is possible to reference the embedded macro, and run it. You can view the XML of the macro, but I know of no way of running it or even accessing it beyond it's XML stored as a string. A possible work around would be to convert all macros to VBA. To do this:
Open the form in design view.
Click Convert Form's Macros to Visual Basic
now you should be able to call the button's code with btnName_Click as you showed in your question. Obviously if you did this, you would sacrifice the advantage of using macros (i.e. limited functionality without the user needing to trust your database).
Original Answer, which doesn't apply to Embedded Macros:
Use DoCmd.RunMacro
Example:
Docmd.RunMacro(macroname)
where macroname is a string representing the name of the macro.