RPE Script expression Java code variable
Erik Herrmann (15●1●5)
| asked Oct 11 '19, 10:02 a.m.
edited Oct 11 '19, 5:57 p.m. by Fariz Saracevic (919●6●13) Hello, in RPE I want to format the date of a field from the ISO8601 format to a more readable format.
RPE provides an example java script to do this. I used this script and put it into the script expression field as per the attached image. The code works fine when I click the "Test Script" button and manually enter the date. It also works fine when I uncomment the first line of the code to assign a date to "modified". However, I want the date to be inherited dynamically from the datasource. But when I do this, I get an error that says the date is blank.
How can I indicate that the date should come from the "modified" variable? This variable should not be blank.
edit - I do not have enough "reputation points" to include a helpful image for my question. So instead here is the code.
It may be unclear from just the code, but the variable "modified" is from $47 - datasource\artifact\colaboration\modified
*********
//modified = "2018-05-15T16:11:06.363+0000";
var currDtFmt = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
var curDt = currDtFmt.parse(modified);
var expDtFmt = new java.text.SimpleDateFormat("MM-dd-yyyy");
var dateString = expDtFmt.format(curDt).toString();
dispaly = dateString;
************
|
Accepted answer
The formatting pattern returned by DNG fails to match and hence it is not working. Please try using the following Script Expression (that uses only date part from "modified" value returned from DNG):
dateString;
Also, it is good to have this code within try-catch block.
Erik Herrmann selected this answer as the correct answer
|
One other answer
Had to change one line, but otherwise it worked.
should have been
display = datestring;
Thanks so much for the help!
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.