How to get the record producer name in the short description of the task

vince_france
Tera Contributor

Hello to all !

I'm looking for the best way to send tasks like Change, HR_Case or Incident,

from a record producer,

with the name of the record producer in the short_description.

For example :

find_real_file.png>>>find_real_file.png

Nothing found in the wiki,

I'm sure you've did this before, can you give me some advice ?

Thank you !

1 ACCEPTED SOLUTION

deepakgarg
ServiceNow Employee
ServiceNow Employee

Hi Vincent,



One easy way to achieve this would be:


Create a variable on Record producer(name: short_description), as follows:



Screen Shot 2016-09-10 at 12.18.04 PM.pngScreen Shot 2016-09-10 at 9.50.12 AM.png


Dont forget to add Default value as: javascript:current.cat_item


And you're done.


Screen Shot 2016-09-10 at 12.22.29 PM.png


Now, if you want, you can write a Catalog UI policy to hide the variable 'short_description' containing the name of the Record producer, as:



Screen Shot 2016-09-10 at 12.40.06 PM.pngScreen Shot 2016-09-10 at 12.40.20 PM.png



Thanks,
Deepak.


PS: Hit like, Helpful or Correct depending on the impact of the response.


View solution in original post

9 REPLIES 9

jonmulherin
Giga Expert

Vincent,



I'm looking to do this in a manner where I can use the same script, such as a UI Script or possibly a client script, to get the result you're looking for.   I've not yet figured that out but I am able to do it using a catalog client script on each producer.



1.   Created a variable set


2.   Added one single line text variable to it.   Name is unimportant but named mine producer_sys_id


3.   Added variable set to producer


4. UI Policy to hide producer_sys_id


5. onLoad Catalog Client Script for producer with the following



function onLoad() {



  var SYSID = $('sysparm_id').value;


  g_form.setValue('producer_sys_id', SYSID);



}



6. Added the following code to the script section on the producer's "What it will contain" tab.



var gr = new GlideRecord('sc_cat_item_producer');


gr.addQuery('sys_id', producer.producer_sys_id);


gr.query();



if (gr.next())


  ShortDescription = gr.name + ' - ';


else


  ShortDescription = 'T&E Issue - ';



7. Results in:



find_real_file.png


deepakgarg
ServiceNow Employee
ServiceNow Employee

Hi Vincent,



One easy way to achieve this would be:


Create a variable on Record producer(name: short_description), as follows:



Screen Shot 2016-09-10 at 12.18.04 PM.pngScreen Shot 2016-09-10 at 9.50.12 AM.png


Dont forget to add Default value as: javascript:current.cat_item


And you're done.


Screen Shot 2016-09-10 at 12.22.29 PM.png


Now, if you want, you can write a Catalog UI policy to hide the variable 'short_description' containing the name of the Record producer, as:



Screen Shot 2016-09-10 at 12.40.06 PM.pngScreen Shot 2016-09-10 at 12.40.20 PM.png



Thanks,
Deepak.


PS: Hit like, Helpful or Correct depending on the impact of the response.


Deepak Ingale1
Mega Sage

Hi Vincent, http://www.servicenowguru.com/reporting/identify-servicenow-record-producer-create-record/ Above article might assists you. For record producers, there in no direct relationship OOB between Record producers and TASK. We see this relationship between catalog item and sc_req_item (RITM). sc_req_item table has a reference field referencing to sc_cat_item table( cat_item is field name). This is very easily possible for catalog items and service requests. For record producers, you might have to check above article


Thanks Deepak Ingale.. upon review and reading the comments from servicenowguru.com link you provided someone posted what worked for me.   I added to the Script field the following to get the name of the Template used:



var template = cat_item.template.name;


Steve L_
Tera Contributor

Here is a business rule script on before insert that worked for us for each table:

(function executeRule(current, previous) {
    var rpid = RP.getParameterValue('sysparm_id');
    var rpt = new GlideRecord('sc_cat_item_producer');
    rpt.addQuery('sys_id', rpid);
    rpt.addQuery('sys_id', '!=' ,'');
    rpt.query();
    if (rpt.next()) {
  current.short_description = current.short_description + " - Using Producer: " + rpt.name;
    }
})(current, previous);