When user clicks button in the esc portal it should navigate to mentioned record producer with value

Kishor O
Tera Sage

I have a custom create incident button in the esc portal under the knowledge article, on click of that button it should navigate to open an incident record producer along with that it should populate the short_description variable of the record producer to Knowledge article title or name then user will fill the required details and submits the form.

 

Please have a look on the image to understand the requirement in better way

KishorO_0-1698991721950.png

 

 

1 ACCEPTED SOLUTION

Hi Kishor,

Apologies for late response. Sure I'll help you out.

 

UtpalDutta_0-1699017709849.png

 

Put your URL in url variable but don't remove this line ('&short='+c.data.shortDesc;)

 

This will get the knowledge short description from the Server. 

 

Once the above URL is opened in new window you will notice that the short description of Knowledge Article is in the URL after short keyword.

 

Now you only need to run below Client script and you will get the short description.

 

var url = new GlideURL(top.window.location.href);
var test =  GlideURL.getParam('short');
g_form.setValue('your variable name', test);

 

Please mark my answer correct if it resolves your issue.

 

Thanks,

Utpal

View solution in original post

5 REPLIES 5

Utpal Dutta
Tera Guru

Hi Kishor,

You need to do two things to achieve this requirement:

 

  1. Pass the Short description of KB article in the URL when user clicks 'Create Incident' button. To do so in your button widget where you're passing the URL of Record producer just append the URL with &. eg: https://dev82040.service-now.com/incident&short_desc=I am here
  2. Create an onLoad client script in for your record producer and fetch this 'short_desc' value and set it in Short description of the Record producer using below script.
var url = new GlideURL(top.window.location.href);
var test =  GlideURL.getParam('paratmeter of the url you want to get');
g_form.setValue('your variable name', test);

 

If my answer was helpful then please mark it Correct!

 

Thanks,

Utpal

@Utpal Dutta Can you guide me on what we need to include in the widget side?

I created a button where should I place the URL link in the widget.

Thanks

Hi Kishor,

Apologies for late response. Sure I'll help you out.

 

UtpalDutta_0-1699017709849.png

 

Put your URL in url variable but don't remove this line ('&short='+c.data.shortDesc;)

 

This will get the knowledge short description from the Server. 

 

Once the above URL is opened in new window you will notice that the short description of Knowledge Article is in the URL after short keyword.

 

Now you only need to run below Client script and you will get the short description.

 

var url = new GlideURL(top.window.location.href);
var test =  GlideURL.getParam('short');
g_form.setValue('your variable name', test);

 

Please mark my answer correct if it resolves your issue.

 

Thanks,

Utpal

@Utpal Dutta  I have implemented following code but button is not responding once I click on it.

 

HTML script

<div>
<button class="btn btn-primary pull-right m-b" ng-click="createIncident()">Create Incident</button>
</div>>

 

 

Server script

 

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */

var sysID = $sp.getParameter('sys_id');
var grKA = new GlideRecord('kb_knowledge');
grKA.get(sysID);
data.shortDesc = grKA.getValue('short_description');

})();

 

 

Client controller

..................................

api.controller = function() {
    /* widget controller */
    var c = this;
 
    c.createIncident = function() {
window.open(url,'');
 
 
    }
};
 
KishorO_0-1699028373666.png