- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 05:22 AM
Dear all,
I am trying to display a clickable link on my task form in order to allow user to jum to a knowledge base article.
In have try to add a field of type URL, but the problem is that it shows the whole URL syntax instead of only the text needed.
I could not find a way to display just the text.
So I open my task form in design and add an Annotation field with HTML format. If I past directly in my generated link to my KB article, it works as expect and I get only KB45357 display and when I click I jump to my item
Q1 :
The question I have now is that has my annotation URL cannot be the same all time , how can I access from script the annotation field in order to change the link from script ?
Thanks for help
regards
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 04:15 AM
we find the solution by implementing the Attached knowledge field into a form and associate a knowledge article to a task
thks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 06:01 AM
Hello,
How you are deciding the URL?
If you are passing URL from BR, the you can follow below approach.
Create a on display BR on task table and set the URL to want to pass in g_scratchpad and in client side you can read the same value. below is the doc of the same.
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/app-store/good_practices/client_script/reference/r_ServerDataExampleScratchpad.html
then in client script, you can set this to HTML annotation tag. I assume you have <a> tag in annotation with unique id. retrieve that object with that tag and set the URL.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 06:16 AM
From a BR script I am creating a task and during task creation I am creating a URL to a KB article.
This is this URL I need to place in my annotation.
But how can I access the annotation field in my form as it as no name due to teh fact it is not a database field
For the annotation, I simply add it from Form design and it did not ask about any id or what so ever.
What do you mean, can you explain in detail what should I do ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 06:32 AM
Example annotation:
<div id="Ali"></div>
use below statement in client script to set URL:
document.getElementById("Ali").innerHTML = '<a href = "https://www.google.com" target="_blank">Google</a>';
Note: DOM manipulation is not recommended by servicenow. But i am not sure of any other method than this.
May be iamkalai has better way than this.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 06:38 AM
ok but you said I need to create a client script, but how to attached the client script on the TASK load ?
regarsd

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 06:45 AM
I assume you still have earlier URL type field where you are setting KB url while creating task.
Create one onLoad script on sc_task(Hope you are using this table only) table and first read that variable value in script using g_form.getValue() and then you can set the same URL to annotation div id as stated above.
Here have your earlier URL field added in the form. you can just hide it using new UI policy or you can hide it in the same script above.
Let me know if you query was different.
Thanks,
Ali
Thank you,
Ali