Fields from current record in slash commands? #438
-
Is it possible to add a field from the current record to a slash command. For example, if I'm on an update set in dev, and I want to jump to the same update set in test's retrieved update sets, I could go to this URL: https://mytestinst.service-now.com/sys_remote_update_set_list.do?sysparm_query=update_source%3D<sys_id of source>%5Ename%3D If I want to build a slash command to do that, I could hard code everything up to "name%3D" in the slash command, but how can I have the slash command pull the name field from the current record? Is that even possible? I know there my be other ways to solve this specific use case. I'm more interested in the generic use case where I want to put any field on a form into a slash command in the same way I would put $sys_id or $table_name. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 5 replies
-
Interesting idea, SN Devs Slackers like it as well :) |
Beta Was this translation helpful? Give feedback.
-
In the years I've been using this, it's the first time I've come across a
use case, so I can't say that I have any others. I thought maybe there was
a way to do it already. If there's not, I'm not sure my single use case
warrants a code change, to be honest.
…On Tue, Sep 26, 2023 at 5:40 PM arnoudkooi ***@***.***> wrote:
Interesting idea, SN Devs Slackers like it as well :)
I'll give it a thought.
Do you see other use cases as well?
—
Reply to this email directly, view it on GitHub
<#438 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAU2UV6WUTGAAVCLY4IX733X4NDUHANCNFSM6AAAAAA5H5LI2I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
You can build your slash command using JavaScript and simply use g_form.getValue('...'). |
Beta Was this translation helpful? Give feedback.
-
You can what now? How do you build a slash command with JavaScript?!?!
…On Tue, Sep 26, 2023 at 5:45 PM tomasz-q ***@***.***> wrote:
You can build your slash command using JavaScript and simply use
g_form.getValue('...').
—
Reply to this email directly, view it on GitHub
<#438 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAU2UV4IHDDA4I6SSPDRRD3X4NEGHANCNFSM6AAAAAA5H5LI2I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
And that's the slash command, instead of something like
"/$table_name.do?sysparm_query=sys_id=$sys_id" ??
…On Tue, Sep 26, 2023 at 6:08 PM tomasz-q ***@***.***> wrote:
With javascript: prefix. Here is an example. I use it to open a new update
set form while being on the rm_story form. The update set's name is
generated based on the current story.
javascript:(function () {
var initials = 'NN';
var g_user = window.g_user || window.frames[0].g_user;
var g_form = window.g_form || window.frames[0].g_form;
if (g_form.tableName != 'rm_story') {
g_form.addInfoMessage('This slash command works on rm_story form only!');
return
}
if (g_user) {
initials = g_user.firstName[0] + g_user.lastName[0];
}
var number = g_form.getValue('number');
var name = initials + ' - ' + number + ' - ' + g_form.getValue('short_description');
var frame = top.gsft_main;
if (!frame) {
frame = top;
}
frame.location = '/sys_update_set.do?sys_id=-1&sys_target=sys_update_set&sysparm_query=name='+name;
})()
—
Reply to this email directly, view it on GitHub
<#438 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAU2UV77J2JWWKVP3WY5TJLX4NG6NANCNFSM6AAAAAA5H5LI2I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
That is friggin' AMAZING! I'm going to share that at work tomorrow, and I
bet people are going to love it!
THANK YOU SO MUCH!
…On Tue, Sep 26, 2023 at 6:22 PM arnoudkooi ***@***.***> wrote:
I did a simple test (that makes no sense) but this does seem to work...
javascript:window.open("https://www.google.com/search?q=" + (g_form?.getValue('number') || ""))
—
Reply to this email directly, view it on GitHub
<#438 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAU2UV55QHEUG3LN55WD273X4NIQPANCNFSM6AAAAAA5H5LI2I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Cool, did you get it to work? If so, please share the command you ended up using. |
Beta Was this translation helpful? Give feedback.
-
I did! Here it is: javascript:window.open("https://.service-now.com/sys_remote_update_set_list.do?sysparm_query=update_source%3D<sys_id>%5Ename%3D"+g_form.getValue("name")); Works like a charm! Thanks again, @tomasz-q, and thanks again for a great tool, @arnoudkooi! |
Beta Was this translation helpful? Give feedback.
With javascript: prefix. Here is an example. I use it to open a new update set form while being on the rm_story form. The update set's name is generated based on the current story.