Getting null fields in crystal reports - crystal-reports

I have a customer name with first name, last name, middle name. I want to concatenate these fields. When I concatenate these fields I am getting some of the fields as null cause as it contains at least one null value field. I have tried with this formula.
{FIRST_NAME}&","&{MIDDLE_NAME}&","&{LAST_NAME}
Ex: I have first name, last name but middle name is null then I am getting entire field as null.
Please help me how to resolve this.

You'll probably want to wrap each field with a formula to adjust for nulls:
// {#FIRST_NAME}
If Isnull({table.FIRST_NAME}) Then "" Else {table.FIRST_NAME}
Then create a formula to concatenate them
// {#FULL_NAME}
{#FIRST_NAME} + "," + {#MIDDLE_NAME} + "," + {#LAST_NAME}

Related

PostgreSQL - How to match a value in a table where column has values with comma separation

I have a table with the following field values:
I want to do a select where I can match a value from this keyword column. For example:
SELECT templateid FROM public.templates WHERE keyword='Yes'
I don't want to use LIKE because in the case one of the comma-separated values is Yessy then I will get a return and that's not correct.
It has to be an exact match of one of the comma separated values.
Any clue?
You can convert the string into an array:
SELECT templateid
FROM public.templates
WHERE 'Yes' = any(string_to_array(keyword, ','))

Zend: Problems defining select option with NULL value for submission to INT MySQL field

I have a database field defined as INT with NULL Allowed. The data submitted to this field is produced by a select form element whos values are defined using addMultiOption and addMultiOptions in combination e.g.
$selectData = $dataModel->getPairs();
$updateForm->getElement('type_id')->addMultiOption(NULL, '- Not Selected -');
$updateForm->getElement('type_id')->addMultiOptions($selectData);
The problem is that the NULL I'm trying to assign to the "- Not Selected -" option is being converted to an empty string at some point and MySQL is throwing an error because an empty string is an incorrect integer value.
How can I modify this such that the NULL arrives at the MySQL insert as a NULL?
Regards,
Nick
EDIT: See Daniel Gadawski's answer below. Below is the final result.
$selectData = $dataModel->getPairs();
$updateForm->getElement('type_id')->addFilter(new Zend_Filter_Null());
$updateForm->getElement('type_id')->addMultiOption('', '- Not Selected -');
$updateForm->getElement('type_id')->addMultiOptions($selectData);
This allows the value NULL to be written to a MySQL Integer field with NULL Allowed.
Add Zend_Filter_Null to this field:
$updateForm->getElement('type_id')->addFilter(new Zend_Filter_Null());
Then just retrieve data from this form using $updateForm->getValues() and the empty strings will be replaced by null values.

how can i get one value from one field (Crystal report)

I get one field V_Name from Database is"Name,StartTime:13:56,EndTime:16:56", how can i just get only one value 13:56 from it? i only want the start time under the column start time. i've tried choose(1,table.field) but it seems only take the first index Name, and the return type should be string. please suggest. Thanks
Try:
// {#end_time}
// create array from comma-delimited list
Stringvar Array values := Split( "Name,StartTime:13:56,EndTime:16:56", ",");
// extract "16:56"; convert to time
Time( Split( values[3], ":")[2] + ":" + Split( values[3], ":")[3] );
If the format of the string is always the same you can get the value between character 16 and 21. Create a formula "StartTime" and place this code there:
Mid ("Name,StartTime:13:56,EndTime:16:56",16 ,5 )
This should return 13:56
To make it a real formula replace "Name,StartTime:13:56,EndTime:16:56" with your field, it will be something like {table.V_Name}.

concatenate without losing thousands separator

I have a report that brings total sales and total probability sale.
The request was that this be shown in one table as "R"{totalamount}" (R"{totprobamount")".
So i added this together in a variable with the variable expression being
"R" + $F{Totalt} +" (R" + $F{Totalp} +")"
but by doing this the Thousands separator does not show anymore?
If you can add a field for each value you wouldn't do this with String concatenation but by using patterns on text field. add for each field in the properties panel a patter such as R #,##0.00.
if it has to be in a single field you'd need to add an expression to actually format the numbers in the desired way such as for example: "R" + new DecimalFormat("#,##.00").format($F{Totalt}) + " (R" + new DecimalFormat("#,##.00").format($F{Totalp}) + ")"
You can use the FORMAT function to have thousand separator.
FORMAT({totalamount} +{totprobamount},2)
This column become String column so you have to add this column separately , you cant use same column for integer value. Where 2 is for up to 2 decimal value.

Crystal Report Parameter Array Index value

I have a Crystal Report with a formula on the page header like this:
dim t as string
t = "DD Waiver Waitlist "
if {rpt_xtab_waitlist.CountyName} = "statewide" then
t = t + {rpt_xtab_waitlist.CountyName}
else
t = t + "for " + {rpt_xtab_waitlist.CountyName} + " County"
end if
formula = t
The problem is not all counties have data for the report, but I still want the page header to contain the county name.
Ultimately, other staff puts a front-end on the report with a combo box for the parameter listing all of the counties, so the parameter UI will not come from Crystal. I can't just change the parameter to dynamic.
I thought I could use the county name from the parameter instead of the data, but that's in an array and I can't figure out how to index it.
I tried:
if {rpt_xtab_waitlist.CountyName} = "statewide" then
t = t + {?County}( RecordNumber)
else
t = t + "for " + {?County}( RecordNumber) + " County"
end if
but it doesn't print the county name corresponding to the selected county in the group tree.
How should I index a parameter array in a formula?
Thanks for any help,
-Beth
Sample county names:
Anoka
Hennepin
Yellow Medicine
Output I get now:
report with page header function suppressed when they select Yellow Medicine county as their parameter from the list of counties
Output I want to get:
report with page header function returning "DD Waiver Waitlist for Yellow Medicine County"
when Yellow Medicine county selection criteria applied returns 0 rows.
I don't think there is a useful index, and for our purposes, they can only select one county as a parameter, so I ended up using the (1) index of the parameter array.
If anyone knows of a way to derive a meaningful index, please post.