Script Input Not Being Passed Correctly from Skill to Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello Everyone,
I am facing an issue while invoking a Script Include through a Script Tool configured in a ServiceNow Skill. I would appreciate your help in understanding and resolving this issue.
Scenario:
I have created a Skill that invokes a Script Tool.
The Script Tool is configured to call a Script Include.
I have defined an input parameter named taskRecordId with the data type String.
The complete value is passed from the Skill input to the Script Tool input and is then forwarded to the Script Include.
Issue:
The input parameter is defined as a String, and the complete value is available at the Skill level. However, when the Script Tool passes the value to the Script Include, only the first character is received.
Example:
Expected value: CS0001154
Actual value received in Script Include: C
Due to this issue, the Script Include is not receiving the complete record number, preventing it from executing the intended functionality correctly.
Questions:
Why is the String input parameter being truncated to its first character when passed from the Script Tool to the Script Include?
Is there any specific configuration required for input parameter mapping between the Skill, Script Tool, and Script Include?
Has anyone encountered a similar issue, and is there a recommended solution or workaround?
Any suggestions or guidance would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @TamilarasiB ,
Getting only "C" from "CS0001154" almost always means the string is being read by index somewhere, as if it were an array. "CS0001154"[0] returns "C".
Check the Script Tool and the Script Include for things like value[0], charAt(0), var [id] = value, or a method that expects an array or object but receives the plain string. Also make sure taskRecordId is a String type (not a list) at both the Skill and Script Tool level.
To find exactly where it changes, log the value at each step:
gs.info('taskRecordId: ' + inputs.taskRecordId + ' | type: ' + typeof inputs.taskRecordId);
and pass it on as String(inputs.taskRecordId).
If it still doesn't work, could you share your Script Tool script and the Script Include method (with any sensitive details removed)? Then we can pinpoint the exact line causing it.
Hope this helps. If it does, please mark it as helpful or accept it as the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
35m ago
Hi @TamilarasiB
Could you share your Script Tool script and the Script Include method (with any sensitive details removed)? Then we can find exactly where the value is being cut to the first character.
As an alternative, you could change the tool input's data type from String to Record (pointing to the relevant table) instead of passing the number as a string. The record is then passed directly, and in your script you can read its fields and sys_id without looking it up by number, which avoids the string handling issue altogether.
Hope this helps. If it does, please mark it as helpful or accept it as the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
18m ago
Hello @TamilarasiB ,
Can you test the Script Tool with a hardcoded value CS0001154 instead of {{taskrecordid}} ?
If the Script Include then receives the full value, the issue is occurring during Skill to Script Tool variable binding rather than in the Script Include itself.
Also add this logs at the very beginning of the Script Include:
gs.info('Input value: ' + taskRecordId);
gs.info('Type: ' + typeof taskRecordId);
gs.info('JSON: ' + JSON.stringify(taskRecordId));
If my response helped mark as helpful and accept the solution.