hyphen causes truncation

Mike Allen
Mega Sage

I have a normal business rule that takes a string value and writes it to another table, like so:

if(current.wf_activity.getDisplayValue() == 'Approver'){

  updateSummarizer(current.sysapproval, 'Approval Comments', current.state + ' - ' + current.comments.getJournalEntry(-1), 190);

}

And then a function to do this:

function updateSummarizer(reqItem, label, value, order){

  var summ = new GlideRecord('u_item_summary');

  summ.initialize();

  summ.u_request_item = reqItem;

  summ.u_label = label;

  summ.u_value = value;

  summ.u_display_order = order;

  summ.insert();

}

The issue I ran into is, if the current comments has a hyphen in it, the data gets inserted into my summary table truncated at that hyphen.   They are both string fields, both set to 4000 chars, and if I don't use the hyphen, the comments get written across correctly.   The comments get written to the sys_journal_field table correctly, just not my custom table.

This is all in the Global scope, so scoping is not an issue.

Any ideas as to what could be causing this truncation?

1 ACCEPTED SOLUTION

mike_allgire
Giga Guru

I tested it and it works for me when just printing out the value. Do you have any business rules on your custom table that could be clipping it based on the hyphen? I would add in a gs.log to see if the full value value string is getting created before putting it in the field.


View solution in original post

3 REPLIES 3

mike_allgire
Giga Guru

I tested it and it works for me when just printing out the value. Do you have any business rules on your custom table that could be clipping it based on the hyphen? I would add in a gs.log to see if the full value value string is getting created before putting it in the field.


You know when you do something stupid, and you cannot find your stupid thing, and you need someone to point you to that error?   Well, that is exactly what happened here.   I had a BR to scrub the date/time from the comment and replace it with GMT, and it was using hyphen as and array separator.   Thanks for helping me find my stupid mistake.


srinivasthelu
Tera Guru

I know, Before Business rule is not a good idea, when you are dealing with other tables from the script but,   have you tried that?



  1. if(current.wf_activity.getDisplayValue() == 'Approver'){  
  2.   updateSummarizer(current.sysapproval, 'Approval Comments', current.state + ' - ' + current.comments, 190);  
  3. }  

And then a function to do this:





  1. function updateSummarizer(reqItem, label, value, order){  
  2.   var summ = new GlideRecord('u_item_summary');  
  3.   summ.initialize();  
  4.   summ.u_request_item = reqItem;  
  5.   summ.u_label = label;  
  6.   summ.u_value = value;  
  7.   summ.u_display_order = order;  
  8.   summ.insert();  
  9. }