CIVICRM, how to make first or last name optional in contacts? - civicrm

I'm Use civicrm with drupal, and I import data in to contact but my data have some row missing first or last name, and first or last name is compulsory so its not uploaded,
So where is back-end setting for civi where I'm make first or last name optional,
Is that possible?

By default, there are two tests that are run before creating a contact in CiviCRM. You only have to pass ONE of these two tests for the contact to be created.
1) Do they have a first name and a last name
OR
2) Do they have an email.
There is NOT a "back-end setting for civi where [you can] make first or last name optional" but if you have an email address for that contact, it will not be required.
One work around if you need to import contacts that don't have either an email or a first name and last name is to create a dummy email address like 'dummy#example.com' and add this to the data that you are going to import.

This is hacky, but use a spreadsheet to insert "FixThisName" or some findable text and import. You can search and edit in Civi after.

Related

configure index format of neomutt

I am using neomutt and configure the way the senders name is displayed.
(not altering display name in outgoing mails)
index_format can do that, and it's defeault is
%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s
L means author's name.
I like to control author's name and
want that nickname I've set with alias will be displayed.
Is this possible?
You need to set reverse_alias and define aliases for people You want to display with nickname. This will affect displaying on index only as You want - no changes in pager or anywhere else.
Example:
set reverse_alias = yes
alias boss My boss <my.boss#exmaple.org>
reverse_alias in docs: neomutt, mutt

How to compare and substitute strings in Ruby on Rails?

Trying to build a barebones concept in Ruby on Rails that will take a string, map each individual word in this string, compare it and then substitute the word if it matches predefined strings in related databases.
For example: User inputs in text field "What does lol and brb mean?" Hits Submit button. The action gives back the same text with "lol" and "brb" changed to "laughing out loud" and "be right back".
So far I have a Post model & table for the User input that stores the string in the database.
I have an Acronym model & table that has "lol" and "brb" stored in database with a foreign key reference to Acronym_Translate model & table that has "laughing out loud" and "be right back" referenced to "lol" and "brb", respectively.
How would I connect the Post model/table to the Acronym model/table in order to compare the strings in Post and substitute with strings from Acronym model/table? And what command could achieve such function? Would gsub! method work here?
Any help would be appreciated!
Are you sure that you want to connect the Post table to the Acronym table? This means that you would have to identify and keep a record of each instance of an acronym within a post.
You can do this using a many to many relation or if you want to store extra data about each acronym occurrence you should create a link table named AcronymPost and use a has many through relationship between Post and Acronym. When you parse a post value, and when you identify an acronym in the post, you would have to record this in the database and then use gsub to replace the post value with the acronym.
You can iterate through your table of acronyms and use (string).include? method to check if it occurs in the post. Finally, you could use a gsub command to replace the acronym with its translation.

how to match a field name with another field name

I have two fields that run throughout a website that I would like to match so that when a user inputs a value either of the fields, it will match the other field. I'm using Sitecore Rocks and am trying to use a query to do this.
select ##h1#, ##Title#
from /sitecore/Content/Home//*[##h1# !="##Title#"];
update set ##h1# = ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
What am I missing here?
This article talks about tapping in to the item:saving event which allows you to compare the fields values of the item before and after the changes:
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/Intercepting-Item-Updates-with-Sitecore.aspx
Using this, you can determine which field has been amended, then change the other to match.
I've had to do something similar to this when a new field was added, and we wanted to set the initial value equal to an existing field. It may be a bug in Sitecore Rocks, but I found it would only update a field when a static value was part of the query.
When I ran ##h1# = ##Title#, the query analyzer would return the correct number of items updated, but no values were actually updated. However, ##h1# = '<id>' worked perfectly. After trying a number of things, I found this did what I wanted.
update set ##h1# = '' + ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
I hope that helps.

Default django field value when creating from record that is being created

I have People app. I have Person model that has username field. When I add a person and that person does not have an account yet, I click the little plus sign next to the username field and I'm presented with a New User form.
That is okay.
Now I want to create users in this manner: The username should be in a form of {firstname}.{lastname}[.{serial}] fo that John Smith will have username john.smith and another John Smith would be john.smith.1.
How can I pass the firstname and lastname to the new user form? Also: How to check if there's another user with that username and append the serial number to it?
Thank you
If the first and last names are being entered (but not yet submitted) on the Person form, and you want those values to show up in the new user form view, then you'll have to:
a) use JavaScript to grab the first name and last name when the user hits that add button (the "plus button"), then
b) pass those values into a custom view that dynamically creates the {firstname}.{lastname}.[serial], then
c) assign that value to form.fields['username'].initial
When the user sees the next form, they will have the value you entered pre-populated. This logic should probably go in a custom form method (whichever form manages the username).
This strategy brings up other issues you'll have to address:
1) What if the user changes the First and Last name in the original Person form, before submitting? (#2 below might solve this)
2) Every time the first or last name are changed, you'll have to update the username on the other model
Other things to consider:
You could do this using a custom user model (docs, tutorial), and put those first and last names in the same model, which could eliminate the custom view creation, allow you to create the username dynamically in one page, and make it easier to sync them.

How do I search a db field for a the string after a "#" and add it to another db field in django

I want to have a content entry block. When a user types #word or #blah in a field, I want efficiently search that field and add the string right after the "#" to a different field as a n entry in a different table. Like what Twitter does. This would allow a user to sort by that string later.
I believe that I would do this as a part of the save method on the model, but I'm not sure. AND, if the #blah already exists, than the content would belong to that "blah"
Can anyone suggest samples of how to do this? This is a little beyond what I'm able to figure out on my own.
Thanks!
You can use regex (re) during save() or whenever to check if your field text contains #(?P<blah>\w+) , extract your blah and and use it for whatever you want .