ajrey77
12/05/2024, 8:09 PMCeligo AI
12/05/2024, 8:09 PMAI generated answer (using internal Slack threads):To persist data in a Suitelet as the user navigates pages, you can use session variables. You can set a session variable using
runtime.getCurrentSession().set()
and retrieve it using runtime.getCurrentSession().get()
. This allows you to store and retrieve data across different pages of the Suitelet.
Here is an example of how you can set and get session variables:
javascript
// Setting a session variable
var session = runtime.getCurrentSession();
session.set({ name: 'myVariable', value: 'myValue' });
// Getting a session variable
var session = runtime.getCurrentSession();
var myVariable = session.get({ name: 'myVariable' });
Another way to persist data across pages is by using hidden fields in the form that the Suitelet is presenting. You can then read these hidden fields in the client script using currentRecord
.
If you want to navigate back to the initial part of the Suitelet (the 'GET' part), you can update the location in the URL. Here is an example of how you can do this:
javascript
function startOver(){
let suiteURL = url.resolveScript({
scriptId: "customscript_your_script_id",
deploymentId: "customdeploy_your_deployment_id"
});
NS.form.setChanged(false); // prevents NS complaining you are leaving the page
document.location.href = suiteURL;
}
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
12/05/2024, 8:09 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826381207
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811939955
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803493
Celigo AI
12/05/2024, 8:09 PM