Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Record Producer variable mapped to journal field

kchorny
Tera Guru

I have a record producer with a Notes variable (Multi line text).   It currently maps to a string field on the table and that works fine.   But when more notes are added to the record, they just append to the previous and becomes difficult to read/manage.   I wanted to change the variable to map to a journal field instead so that I could more easily extract the most current note, but after I changed the mapping, nothing was transferred anywhere from the Notes variable.

Is there a trick to mapping to a journal field from a record producer?

TIA!

7 REPLIES 7

Chuck Tomasi
Tera Patron

Hi Karla,



Unmap it and try this in your record producer script field (change the u_journal field and notes variable names accordingly)



current.u_journal_field = producer.notes;   // copy producer's text field to final record's journal field.


Thank you both for the quick (simultaneous!) responses.   I have done no work with record producers before - this one was created by a 3rd party and now I'm attempting to make a few minor changes.



I tried your method above....


Steps:


Unchecked Map to field on the Notes variable


Commented line 33, added lines 34 and 55


Tested - no go.


Then I changed line 34 to:


gr.u_task_notes.setJournalEntry(producer.u_notes);


and line 55 to


current.u_task_notes.setJournalEntry(producer.u_notes);


Still no go.  


What the heck am I doing wrong?



  1. createTimeEntry();
  2. function createTimeEntry(){
  3.   var today = producer.entry_date;
  4.   var dow = new GlideDateTime(today);
  5.   dow = dow.getDayOfWeekUTC();
  6.   var dtUtil = new DateTimeUtils();
  7.   if (dow != 1) //if the day of the week is not Monday, determine what the date's time card week start day is
  8.   var start = dtUtil.getWeekStart(today, 1);
  9.   else
  10.   var start = today;
  11.   var reportingPer = String(producer.entry_date);
  12.   reportingPer = reportingPer.substr(0,4) + reportingPer.substr(5,2);   //string manipulation to grab reporting period date YYYYMM
  13.   var user = producer.user;
  14.   var gr = new GlideRecord('time_card');
  15.   gr.addQuery('week_starts_on', start);
  16.   gr.addQuery('user', user);
  17.   gr.addQuery('u_reporting_period', reportingPer);
  18.   gr.addQuery('u_company', producer.u_company);
  19.   gr.addQuery('u_service_contract', producer.u_service_contract);
  20.   gr.addQuery('task', producer.task);
  21.   gr.addQuery('u_operational_task', producer.u_operational_task);
  22.   gr.addQuery('category', producer.category);
  23.   gr.query();
  24.   var hours = parseFloat(producer.hours);
  25.   if(gr.next()){ //Looking for any pre-existing timecards and updating them
  26.   current.setAbortAction(true);
  27.   if(gr.state == 'Approved'){
  28.   gs.addInfoMessage("Time card has already been approved. No additional time can be entered.");
  29.   return;
  30.   }
  31.   //gr.u_notes = gr.u_notes + ' ' + producer.u_notes;
  32.   gr.u_task_notes = producer.u_notes;
  33.   if(dow == 1)
  34.   gr.monday = parseFloat(gr.monday) + hours;
  35.   else if(dow == 2)
  36.   gr.tuesday = parseFloat(gr.tuesday) + hours;
  37.   else if(dow == 3)
  38.   gr.wednesday = parseFloat(gr.wednesday) + hours;
  39.   else if(dow == 4)
  40.   gr.thursday = parseFloat(gr.thursday) + hours;
  41.   else if(dow == 5)
  42.   gr.friday = parseFloat(gr.friday) + hours;
  43.   else if(dow == 6)
  44.   gr.saturday = parseFloat(gr.saturday) + hours;
  45.   else
  46.   gr.sunday   = parseFloat(gr.sunday) + hours;
  47.   gr.update();
  48.   producer.redirect= "time_card.do?sys_id=" + gr.sys_id;
  49.   }
  50.   else{ //No pre-existing timecard was found, update current record with inputted values
  51.   current.week_starts_on = start;
  52.   current.u_reporting_period = reportingPer;
  53. current.u_task_notes = producer.u_notes;
  54.   if(dow == 1)
  55.   current.monday = producer.hours;
  56.   else if(dow == 2)
  57.   current.tuesday = producer.hours;
  58.   else if(dow == 3)
  59.   current.wednesday = producer.hours;
  60.   else if(dow == 4)
  61.   current.thursday = producer.hours;
  62.   else if(dow == 5)
  63.   current.friday = producer.hours;
  64.   else if(dow == 6)
  65.   current.saturday = producer.hours;
  66.   else
  67.   current.sunday = producer.hours;
  68.   }
  69. }


find_real_file.png


Not sure what to tell you Karla. I just took the out of box record producer for "Something is broken" that creates an incident. I added a multi-line text field for u_notes and copied them over to the incident's comments field like this:



find_real_file.png



Everything worked fine. (my text in the u_notes variable was "Comments go here")


find_real_file.png



Without being able to reproduce it, I'm not sure what to tell you.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Karla,



I don't think you can map multi line to journal field. The alternative option is via scripting on record producer. Adjust field column names as per your req.


i.e current.work_notes = producer.VARIABLENAME;


Screen Shot 2016-07-14 at 1.54.19 PM.png