Discussion

Display Substring of a field

((I had posted this on the pega forums and not the PDN section, so I am posting here as there are a lot more answers to be found here))

I am looking to find a function that will enable me to extract a field and place it on a report, but I am only wanting to display a partial piece of a lengthy string. i.e. in a report where you have the tabs along the top - content,drilldown,organize....history - If I select the Dilldown tab where I can select the fields I need displayed with a caption, I assume that in the HTML property I should be able to use a function to perform the equvilent of a SUBSTRING feature where it can specify startpossition and length for a field of what to display.(using the magnify icon next to field)

ie Field value = "Start:clientname.location-state" using substring(6,10) will show "clientname" and other varients (len() ) etc?

do I need to write this in Java or is there something already available ?
-----
there was a suggestion from hsoneji :
Try this in HTML Property and apply that to the field column in your report you want format.

<%
String fmtStr = tools.getActiveValue().substring(1, 2);
tools.putSaveValue("result", fmtStr);
%>
-------
BUT - I tried that and it did not do anything to the report, but it could have been my misunderstanding on how to implement.

I have not yet figured out how to perform this seemingly simple task. Any help is appreciated.
Thanks

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

December 13, 2010 - 2:28pm

Hey ROSSLIN???,
I think the code you posted shud work except for the fact that you are saving the value, but not displaying it. Add the below line to your code and I guess it should work:
<pega:reference name="$SAVE(result)" />

cheers!!
Arjun

quote:


Originally posted by ROSSLINFOOT

((I had posted this on the pega forums and not the PDN section, so I am posting here as there are a lot more answers to be found here))

I am looking to find a function that will enable me to extract a field and place it on a report, but I am only wanting to display a partial piece of a lengthy string. i.e. in a report where you have the tabs along the top - content,drilldown,organize....history - If I select the Dilldown tab where I can select the fields I need displayed with a caption, I assume that in the HTML property I should be able to use a function to perform the equvilent of a SUBSTRING feature where it can specify startpossition and length for a field of what to display.(using the magnify icon next to field)

ie Field value = "Start:clientname.location-state" using substring(6,10) will show "clientname" and other varients (len() ) etc?

do I need to write this in Java or is there something already available ?
-----
there was a suggestion from hsoneji :
Try this in HTML Property and apply that to the field column in your report you want format.

<%
String fmtStr = tools.getActiveValue().substring(1, 2);
tools.putSaveValue("result", fmtStr);
%>
-------
BUT - I tried that and it did not do anything to the report, but it could have been my misunderstanding on how to implement.

I have not yet figured out how to perform this seemingly simple task. Any help is appreciated.
Thanks


Pega
December 13, 2010 - 2:45pm

replace: tools.putSaveValue("result", fmtStr);
with: tools.appendString(fmtStr);

December 13, 2010 - 3:53pm

Thanks very much for the help - It works :)
<%
String fmtStr = tools.getActiveValue().substring(0, 4);
tools.appendString(fmtStr);
%>

The above pulls the first 4 characters starting at position 0.

The tools.appendString made the difference at the end

December 21, 2015 - 7:19am
Response to Ross.Linfoot

Hi,

How to pull the last 4 characters