In report function field, how to extract specific text from another text field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 12:11 PM
Hello,
I am creating a report currently on a table. That table has a description field, pretty much a text field whose value look something like this:
Random text
Repository: repository name
Created by: John
Would I be able to extract just "repository name"? I want this for a report. I was wondering if we can extract that with a functional field in the report. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 01:39 PM
Hi,
I have no idea what a 'functional field' in a report is. However, script logic for your example is:
var desc = "Random text\nRepository: repository name\nCreated by: John"
gs.info(desc);
var repoStr = desc.substring(desc.indexOf('Repository: '));
var nl = repoStr.indexOf('\n'); // assuming the desired value is on a line by itself
var repo = repoStr.substring(12, nl);
gs.info('repo = ' + repo + '.');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 01:53 PM
i think, functional field referring the column create for reporting this "Repository:" values along with other table column, this functional field not a column in source table.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Absolutely, this can be done. If the repository name always appears after "Repository:" in the description field, you can extract it using a calculated/functional field with a substring function.
For example, let's take logic in SQL:
SUBSTRING(description,
CHARINDEX('Repository:', description) + LEN('Repository:'),
CHARINDEX('Created by:', description) -
(CHARINDEX('Repository:', description) + LEN('Repository:')))
