how can i get the id of the that is logged into th...
# ask-stanley-ai
a
how can i get the id of the that is logged into the vendor center in a suitelet that is accessed via a link on the vendor centers?
c
AI generated answer (using internal Slack threads):
To get the ID of the user that is logged into the Vendor Center in a Suitelet that is accessed via a link on the Vendor Centers, you can use the
runtime
module in SuiteScript 2.0. The
runtime
module provides methods that allow you to access information about the current user and the script execution context. Here is a sample code snippet:
Copy code
javascript
var runtime = require('N/runtime');

function suiteletFunction(context) {
    var user = runtime.getCurrentUser();
    var userId = user.id;
    // Now you have the user ID
}
In this code,
runtime.getCurrentUser()
returns a
User
object representing the current user. The
id
property of this object is the internal ID of the user. Please note that this will only work if the Suitelet is executed in the context of a user session, such as when a user accesses the Suitelet via a link on the Vendor Centers. If the Suitelet is executed in a context where there is no user session (for example, if it is called by a scheduled script),
runtime.getCurrentUser()
will return a
User
object representing a special "system" user, and the
id
property of this object will be
-4
. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833108
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817939281
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813402474
Please provide your feedback on this answer.