Prioritise which identifier to use - crystal-reports

My crystal report pulls data about books, including an identifier (isbn, issn order number etc.), author, and publisher.
The ID field stores multiple ways to identify the book. The report displays any of the identifiers for that record. If one book has two identifiers; issn and order number, the report currently displays one apparently at random.
How can I make it prioritise which type to use based on a preset order? I figured some sort of filter on the field could work, but I haven't figured out how. I can't edit the table, but I can use SQL within the report.

If all the different types of ID are stored in a single field, your best bet is to use a SQL Command inside your report to separate them into multiple virtual fields.
Go to Database Fields / Database Expert, expand the connection you want to use, and pick Add Command. From here you can write a custom SQL statement to grab the information you're currently using, and at the same time separate the ID field into multiple different fields (as far as the report will be concerned, anyway. The table will stay unchanged.)
The trick is to figure out how to write your command to do the separation. We don't know what your data looks like, so you're on your own from here.

Based on the very little information that you have provided and if i was to make a guess.I suggest you make use of the formula field in your report and then use something like this to accomplish your goal.
IF ISNULL{first_priority_field_name} OR {first_priority_field_name} = '' THEN
{second_priority_field_name}
ELSE
{first_priority_field_name}
Use nested IF statement in case there are more than 2 identifier fields.

Related

Ignoring space characters when linking tables

I’m experiancing a problem when trying to link to tables in the database expert. The two fields that link the tables have exactly the same information except one table always has an additional space. For example;
Table 1 = Multivitamin/Tablets
Table 2 = Multivitamin//Tablets
‘/‘ are representing spaces
Formulas won’t help (e.g. extractstring etc) as it’s the tables themselves I need to link together
This is preventing me from retrieving the information I need. Any advice on how I can get around this?
There are some ways to come across this:
Consider using a command as datasource instead of tables. When writing the query of the command you can define the join condition yourself.
If you have access to the data source, you could add a calculated field to the tables to contain the normalized field values and then use these for linking in CR.
Alternatively, one could create views in the database, either adding normalized "linking fields" or providing the joined tables results.
If it's only a few rows in CR, you could consider using SQL fields or subreports to retrieve data from Table 2.

adding up specific mergefield values in word

I have a table in a word document that has three colums and all fields are mailmerge fields from an external IT system.
There are three columns displaying the fields:
Charge Description
Charge Value (£)
Eiligible? (yes/no)
I am trying to create a field that adds up all eligibale charges so that only charge values that show a "yes" in the eligigble field are included. Does anyone know if this is possible? I have tried creating a formula but can't get it to work. Also, I would assume at some point an if statment is required so that it only includes the eligible charge.
Has anyone done anything similar before and if so, would they mind sharing how it was achieved?
Many thanks
You can do some things with expression fields (created in Word with CTRL-F9). This will look like {} and you can insert the expression. eg {{MERGFIELD charge} + {MERGEFIELD charge2}}. Since however you want to check multiple values and then create an expression, its probably easier to use a macro. The macro would contain your logic, then set the fields in the document accordingly.
Here are two external links since I can't reproduce a useful amount the content here because it's a verbose answer to a potentially deep question:
Expression Fields
Merge fields
I hope that helps.

How to create table occurrences for filtered data..?

I have a table called transactions. Within that is a field called ipn_type. I would like to create separate table occurrences for the different ipn types I may have.
For example, one value for ipn_type is "dispute". In the past I would create a global field called "rel_dispute" and I would populate that with the value of "dispute". Then I could create a new table occurrence of the transactions table, and make a relationship based on transactions::ipn_type = transactions::rel_dispute. This way only the dispute records would show up in my new table occurrence.
Not long ago, somebody pointed out to me that this is no longer necessary, and there is a simpler way to setup such a relationship to create a new table occurrence. I can't for the life of me remember how that was done, though.
Any information on this would be greatly appreciated. Thanks!
To show a found set of only one type, you must either perform a find or use the Go to Related Record script step to show only related records. What you describe as your previous setup fits the latter.
The simpler way is to perform a find - either on demand, or by a script triggered OnLayoutEnter.
The new 'easy' way is probably:
using one base relationship only and
filtering only the displaying portal by type. This can be done with a global field, a global variable containing current display type. Multiple portals with different filter conditions are possible as well.
~jens

APEX - Can a Tabular Form with its MRU functionality have filtering functionality like an Interactive Report?

What I really need is a Tabular form that allows me to update multiple rows at a time while being filterable like an Interactive report. Any chance this is even remotely possible?
I would also like to hijack the row checkboxes on a tabular form that appear when the 'delete' functionality is activated and use them to select which rows get assigned a to a group based on a common attribute. (i.e. My table contains parts in my inventory and I need to be able to assign parts with common attributes to a group for processing)
Perhaps a group-by function that creates a new row in a 'Group' table with the group as the PK and the parts assigned to that group as a list or something...?
Thoughts? I am kind of at a loss...
It's really not that hard :) You can easily transform an IR into a pseudo-tabular form. And even though there are always more stylish and elegant solutions, those usually involve lots of javascript and/or plugins. They're nice, but not always what you want or need of course.
So how to manipulate your output? Use the APEX_ITEM api!
Quick example. I have an ir built on emp. I added a checkbox and textbox.
select empno, ename, deptno,
apex_item.checkbox(1, empno) empno_selected,
apex_item.text(2, ename, 10, 10) ename_edit
from emp
Don't forget: in the column attributes, set Display text as to Standard Report Column. If you don't, the output will be in plain text. Since apex_item generates html code, you don't want the plain text of course :)
Now, to be able to perform DML based on the actions you do in those generated fields, you will need a process. Let me start off by pointing out though that the generated items are stored in application variables, namely in arrays in APEX_APPLICATION.
Take note of the behaviour of checkboxes: only ticked boxes will have their value stored in the array!
As an example, i've made this small On Submit process (also adding a SUBMIT button on the form to actually perform the submit...)
for i in 1..apex_application.g_f01.count
loop
insert into empselected(empno, selectiondate, ename_changed)
values(apex_application.g_f01(i), sysdate, apex_application.g_f02(i));
end loop;
This will loop over the records with the checkboxes ticked, and insert them into some table. For example, i ticked the box with KING and edited the textfield. See record nr 2 (1 is from a previous action ;))
It's not all the way there yet though. You still miss out on the functionality of a tabular form and it's processes, and things like optimistic locking. If you want to stay with tabular forms, you can also, for example, check out this link. There have also been some questions here about writing your own mru processes etc, like this one ;)
It is possisble, using the same tabular form.
Create an item (text item) in the tabular form region.
Create a submit button (Create a button displayed among this region's items)
Modify the where clause in the tabular form region source
For Example, you need search by customer name:
WHERE lower(CUSTOMER_NAME) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
If you need to search for other field only add other condition to the where clause
WHERE (
lower(CUSTOMER_NAME) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
or lower(CUSTOMER_address) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
)
Simple and use the same tabular form.

coldfusion - bind a form to the database

I have a large table which inserts data into the database. The problem is when the user edits the table I have to:
run the query
use lots of lines like value="<cfoutput>getData.firstname#</cfoutput> in the input boxes.
Is there a way to bind the form input boxes to the database via a cfc or cfm file?
Many Thanks,
R
Query objects include the columnList, which is a comma-delimited list of returned columns.
If security and readability aren't an issue, you can always loop over this. However, it basically removes your opportunity to do things like locking certain columns, reduces your ability to do any validation, and means you either just label the form boxes with the column names or you find a way to store labels for each column.
You can then do an insert/update/whatever with them.
I don't recommend this, as it would be nearly impossible to secure, but it might get you where you are going.
If you are using CF 9 you can use the ORM (Object Relation Management) functionality (via CFCs)
as described in this online chapter
https://www.packtpub.com/sites/default/files/0249-chapter-4-ORM-Database-Interaction.pdf
(starting on page 6 of the pdf)
Take a look at <cfgrid>, it will be the easiest if you're editing table and it can fire 1 update per row.
For security against XSS, you should use <input value="#xmlFormat(getData.firstname)#">, minimize # of <cfoutput> tags. XmlFormat() not needed if you use <cfinput>.
If you are looking for an easy way to not have to specify all the column names in the insert query cfinsert will try to map all the form names you submit to the database column names.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c78.html
This is indeed a very good question. I have no doubt that the answers given so far are helpful. I was faced with the same problem, only my table does not have that many fields though.
Per the docs EntityNew() the syntax shows that you can include the data when instantiating the object:
artistObj = entityNew("Artists",{FirstName="Tom",LastName="Ron"});
instead of having to instantiate and then add the data field by field. In my case all I had to do is:
artistObj = entityNew( "Artists", FORM );
EntitySave( artistObj );
ORMFlush();
NOTE
It does appear from your question that you may be running insert or update queries. When using ORM you do not need to do that. But I may be mistaken.