Tool Object Members Reference for SuiteScript 2.1

Tool Object Members in SuiteScript 2.1 provide essential properties including description, name, and parameters for server scripts.

·2 min read·View Oracle Docs

The Tool Object in SuiteScript 2.1 allows developers to define tools with specific properties that enhance their scripting capabilities. Understanding its members is crucial for constructing robust server scripts.

What Are Tool Object Members?

Tool Object Members are properties that describe various aspects of a tool in SuiteScript 2.1. The key members include:

Member NameReturn TypeSupported Script TypesDescription
Tool.descriptionstringServer scriptsProvides a description of the tool.
Tool.namestringServer scriptsRepresents the name of the tool.
Tool.parametersArray<llm.ToolParameter>Server scriptsContains the parameters of the tool.

Property Descriptions

  • Tool.description: This property returns the description of the tool in string format, useful for documentation and clarity within your scripts.
  • Tool.name: The name of the tool, also returned as a string, which serves to identify the tool when referenced in code.
  • Tool.parameters: Returns an array of llm.ToolParameter objects, each representing a parameter that the tool accepts, allowing for customizable functionality.

Error Handling

When using Tool properties, developers should be aware of error codes such as READ_ONLY, which indicates that an attempt to set a property has been made, which is not permitted.

Example Syntax

Here's a brief example that illustrates the creation of a tool in SuiteScript 2.1:

suitescript
1const findUserIdTool = llm.createTool({
2 name: "findUserId",
3 description: "Looks up user ID based on user name",
4 parameters: [
5 llm.createToolParameter({
6 name: "userName",
7 description: "Name of the user",
8 type: llm.ToolParameterType.STRING
9 })
10 ]
11});
12
13const toolDescription = findUserIdTool.description;

In this code, a tool named findUserId is defined with a specific description and parameters, demonstrating how flexible and powerful the Tool Object can be in your server-side scripts.

Who This Affects

  • Developers: Those working with SuiteScript 2.1 and needing to create or manipulate tools.
  • Administrators: Individuals responsible for managing scripts and tools within NetSuite.

Key Takeaways

  • Tool Object Members are key properties for server scripts in SuiteScript 2.1.
  • Understanding each member facilitates effective tool creation.
  • Error codes like READ_ONLY highlight important considerations during property assignments.

Frequently Asked Questions (4)

Are Tool Object Members in SuiteScript 2.1 applicable to client scripts?
No, Tool Object Members in SuiteScript 2.1 are specifically supported for server scripts only.
What happens if I try to set a value on a read-only Tool property?
Attempting to set a value on a read-only Tool property will result in an error with the code 'READ_ONLY'.
Is it possible to define custom parameters for a tool using SuiteScript 2.1?
Yes, you can define custom parameters for a tool using SuiteScript 2.1 by creating an array of llm.ToolParameter objects and assigning them to the Tool.parameters property.
How can developers use the 'Tool.description' property effectively?
Developers can use the 'Tool.description' property to provide documentation and clarity within scripts by defining a string that explains the tool's purpose and functionality.
Source: Tool Object Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →