Author |
Message |
NCGOV
Newbie
Joined: 04 Oct 2016
Online Status: Offline
Posts: 24
|
Topic: Name Formula Posted: 29 Dec 2017 at 10:48am |
How do I combine these two formulas into one?
Last Name:
local stringvar ln := {unit.name};
if instr (ln, ",") > 0 then
trim(split(ln, ",")[1])
else trim(ln)
First Name:
local stringvar fn := {unit.name};
if instr (fn, ",") > 0 then
local stringvar fo := trim(split(fn, ",")[2]);
if instr(fo, " ") > 0 then
split(fo, " ")[1]
else fo
I want to combine the first and last name formula into one where it will read LAST, FIRST.
Edited by NCGOV - 29 Dec 2017 at 10:52am
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 02 Jan 2018 at 4:01am |
So you are saying you want to return the value Last, First?
Combine the two formulas formulas or call both formulas (change local variables to global or shared variables) and have the following line as the last line in the combined formula (slightly different if you call the formulas).
ln + ', '+ fo
|
IP Logged |
|
NCGOV
Newbie
Joined: 04 Oct 2016
Online Status: Offline
Posts: 24
|
Posted: 10 Jan 2018 at 4:12am |
So is this what you are suggesting?
global stringvar ln := {unit.name};
if instr (ln, ",") > 0 then
trim(split(ln, ",")[1])
else trim(ln)
global stringvar fn := {unit.name};
if instr (fn, ",") > 0 then
local stringvar fo := trim(split(fn, ",")[2]);
if instr(fo, " ") > 0 then
split(fo, " ")[1]
else fo
ln + ', '+ fo
....that did not work.
Edited by NCGOV - 10 Jan 2018 at 4:14am
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 10 Jan 2018 at 4:49am |
Error message? Not the right result?
FYI: I would be wary of declaring a variable in the middle of the code. If you if statement is false then fo is not created. Also make sure you have set 'Default Values for Nulls' in the formula editor.
|
IP Logged |
|
|