I'm making a conditional formula in Crystal Reports for the record selection. The value of {IDENTITY_ADDRESS.ADDRESS_TYPE} can be either 1 (Present Street Address) or 3 (Present Mailing Address).
There will always be a Street Address (1) but I would prefer to use the Mailing Address (3) if one exists. How can I accomplish this?
You'll probably want to write a custom SQL statement inside Crystal to handle this. Since custom-tooled SQL tables evaluate before the report is even reached, it will do the record selection for you.
I can't see your tables so you'll have to write the logic yourself. But the gist is that you'll want to return a new field, let's call it PreferredAddress which will be a varChar that will:
Check to see if a Present Mailing Address (3) is on file for this record
If yes, return the Present Mailing Address (3) as PreferredAddress
If no, return the Present Street Address (1) as PreferredAddress
if {IDENTITY_ADDRESS.ADDRESS_TYPE} = Present Mailing Address
then true,
else
{IDENTITY_ADDRESS.ADDRESS_TYPE} = Present Street Address
Related
I am on Filemaker 18 Pro and new to Filemaker in general. I created a table of Clients and a table of Properties. One client can have multiple properties (ie One to Many relationship). I want to have a flag to indicate that the property is the Client's Primary Address. So basically the field will be:
isPrimary = "Yes" or isPrimary = "No".
There can only be one "Yes" per Client ID
There HAS to be one "Yes" value per Client ID
If you add "Yes" then it will change the existing "Yes" to "No"
Is there a best practice for doing this?
Is there a best practice for doing this?
Yes, there is. If only one property can be the client's primary address, then the identity of the primary address is an attribute of the client, and should be recorded in a field of the Client's table - e.g. a Number field storing the selected property's PropertyID.
To "flag" the primary address, use an unstored calculation, or a conditionally formatted object, using the formula:
Clients::PrimaryAddressID = PropertyID
In this arrangement, selecting a new primary address will automatically remove the flag from the previous address and place it on the newly selected one.
P.S.
It is much more convenient to use the values 0 and 1 (or empty and 1) for Boolean fields. The field itself can be formatted to display as "Yes" or "No".
You can loop the Properties portal/records and set "No" for other records.
I have designed a simple database to keep track of company contacts. Now, I am building a form to allow employees to add contacts to the database.
On the form itself, I have all the columns except the primary key (contactID) tied to a text box. I would like the contactID value to be (the total number of entered contacts + 1) when the Add button is clicked. Basically, the first contact entered will have a contactID of 1 (0 + 1 = 1). Maybe the COUNT command factors in?
So, I am looking for assistance with what code I should place in the .Click event. Perhaps it would help to know how similar FoxPro is to SQL.
Thanks
The method you recommend for assigning ContactIDs is not a good idea. If two people are using the application at the same time, they could each create a record with the same ContactID.
My recommendation is that you use VFP's AutoIncrementing Integer capability. That is, set the relevant column to be Integer (AutoInc) in the Table Designer. Then, each new row gets the next available value, but you don't have to do any work to make it happen.
There are various ways to do this. Probably the simplest is to attempt to lock the table with flock() when saving, and if successful do:
calc max id_field to lnMax
Then when inserting your new record use lnMax+1 as the id_field value. Don't forget to
unlock all
... after saving. You'll want to ensure that 'id_field' has an index tag on it, and that you handle the case where someone else might have the table locked.
You can also do it more 'automagically' with a stored procedure.
I have sugarCRM 6.5.20 OnDemand. I am in the Studio. I have a 1:1 relationship from Leads to Leads. I am trying to get the Primary Email address of the related Lead and display it in a calculated field.
It seems like the calculated field formula should look like:
related($emails,"email1")
When I do that I get the following error:
Invalid formula: related: Unknown Field : email1
The dropdown list doesn't list the email at all. How can I get the email? All of my web searches have proven ineffective.
Update:
I am willing to make the calculated field be the primary email address of the current lead. To do that I found 2 variables named $email_addresses and $email_addresses_primary and $emails. There is also a function called valueAt.
I tried to use valueAt(1,$emails) and valueAt(1,$email_addresses)
The validator accepted the syntax but the value was always empty.
Can I make a calculated field off of the leads primary email?
You won't get the Email field for the Studio's formula calculation. Email field is stored in a separate table and not in the module's table. It is just put in the Layout along with the other fields of the module, but it is not the same as other fields. All the Email Addresses irrespective of the modules are stored together in the email_addresses table and are related to respective module records in the email_addr_bean_rel.
I'm new to reporting services so this question might be insane. I am looking for a way to create an empty 'template' report (that is basically a form letter) rather than having to create one for every client in our system. Part of this form letter is a section that has any number of 25 specific fields. The section is arranged as such:
Name: Jesse James
Date of Birth: 1/1/1800
Address: 123 Blah Blah Street
Anywhere, USA 12345
Another Field: Data
Another Field2: More Data
Those (and any of the other fields the client specifies) could be arranged in any order and the label on the left could be whatever the client decides (example: 'DOB' instead of 'Date of Birth'). IDEALLY, I'd like to be able to have a web interface where you can click on the fields you want, specify the order in which they'll appear, and specify what the custom label is. I figured out a way to specify the labels and order them (and load them 'dynamically' in the report) but I wanted to take it one step further if I could and allow dynamic field (right side) selection and ordering. The catch is, I want to do this without using dynamic SQL. I went down the path of having a configuration table that contained an ordinal, custom label text, and the actual column name and attempting to join that table with the table that actually contains the data via information_schema.columns. Maybe querying ALL of the potential fields and having an INNER JOIN do my filtering (if there's a match from the 'configuration' table, etc). That doesn't work like I thought it would :) I guess I was thinking I could simulate the functionality of a dataset (it having the value and field name baked in to the object). I realize that this isn't the optimal tool to be attempting such a feat, it's just what I'm forced to work with.
The configuration table would hold the configuration for many customers/reports and I would be filtering by a customer ID. The config table would look somthing like this:
CustID LabelText ColumnName Ordinal
1 First Name FName 1
1 Last Name LName 2
1 Date of Birth DOBirth 3
2 Client ID ClientID 1
2 Last Name LName 2
2 Address 1 Address1 3
2 Address 2 Address2 4
All that to say:
Is there a way to pull off the above mentioned query?
Am I being too picky about not using dynamic SQL as the section in question will only be pulling back one row? However, there are hundreds of clients running this report (letter) two or three times a day.
Also, keep in mind I am not trying to dynamically create text boxes on the report. I will either just concatenate the fields into a single string and dump that into a text box or I'll have multiple reports each with a set number of text boxes expecting a generic field name ("field1",etc). The more I type, the crazier this sounds...
If there isn't a way to do this I'll likely finagle something in custom code; but my OCD side wants to believe there is SQL beyond my current powers that can do this in a slicker way.
Not sure why you need this all returned in one row: it seems like SSRS would want this normalized further: return a row for every row in the configuration table for the current report. If you really need to concatenate then do that in Embedded code in the report, or consider just putting a table in the form letter. The query below makes some assumptions about your configuration table. Does it only hold the cofiguration for the current report, or does it hold the config for many customers/reports at once? Also you didn't give much info about how you'll filter to the appropriate record, so I just used a customer ID.
SELECT
config.ordinal,
config.LabelText,
CASE config.ColumnName
WHEN 'FName' THEN DataRecord.FirstName
WHEN 'LName' THEN DataRecord.LastName
WHEN 'ClientID' THEN DataRecord.ClientID
WHEN 'DOBirth' THEN DataRecord.DOB
WHEN 'Address' THEN DataRecord.Address
WHEN 'Field' THEN DataRecord.Field
WHEN 'Field2' THEN DataRecord.Field2
ELSE
NULL
END AS response
FROM
ConfigurationTable AS config
LEFT OUTER JOIN
DataTable AS DataRecord
ON config.CustID = DataRecord.CustomerID
WHERE DataRecord.CustomerID = #CustID
ORDER BY
config.Ordinal
There are other ways to do this, in SSRS or in SQL, depends on more details of your requirements.
I find that in development, in my contacts, ABRecordCopyCompositeName returns NULL for a few records, but when I view my contact list normally, I don't see any missing names.
What's a standard alternative label to use if ABRecordCopyCompositeName returns a NULL? Also, what causes the NULL values to exist in the first place?
(EDIT: title corrected)
Strangely:
The count at the bottom of the "Contacts" iPhone app states 119 contacts.
I counted all entries - all 119 are there and have names.
[ABAddressBookCopyDefaultSource(addressBook) count] returns 116, not 119.
Counting each entry from ABAddressBook, I get 116, including the 3 null entries.
So, on top of three null entries, I'm missing 3 more.
I'm still looking for a better answer, but until then, here's what I've found:
The NULL records are due to records imported from Exchange. They show as having a name, and if you edit them and save them (through the UI) the name shows up correctly, but until then, I can't seem to get a name out of the record.
The three 'missing' records are still confusing me. I believe they are also imported from Exchange, but just not included in the ABAddressBookCopyDefaultSource request.
My work-around was to not fill out table cells directly from ABAddressBook, but to copy the entries into an array first, so that the counts are correct. As I get further toward release, I may circle back to this routine and change it so that very large address books will not cause memory issues.
Not all contacts have stored firstname and lastname just email or some other field... For some reason apple is sorting based on this.. The empty compositename with email address "example#example.com" will appear below the contact named "Edward"... So it makes sense to create a fallback-thingy: if compositename is empty then look for email-address