Function that only proper cases name field values if first letter is not capitalized?
I watched the Zenatta Consulting 3-part youtube series on Zoho functions. So now I’m a pro! 🧐
I created a function that successfully proper cases our Contact record name fields.
But I would like the function to only proper case each name field if the first letter is not capitalized, or (bonus) if all letters are capitalized.
Could someone help me with this? That way, I can avoid altering the names of people who intentionally capitalize more than just the first letter of their name (LeShay, etc.), but I can have a workflow run this function and automatically fix the names with no capitalization or ALL CAPS.
Here’s the base function that just proper cases all the fields when run:
contact = zoho.crm.getRecordById("Contacts",contact_id);
firstName = contact.get("First_Name");
firstNameOnly = contact.get("First_Name_Only");
middleName = contact.get("Middle_Name");
lastName = contact.get("Last_Name");
properFirstName = firstName.proper();
properFirstNameOnly = firstNameOnly.proper();
properMiddleName = middleName.proper();
properLastName = lastName.proper();
updateInformation = {"First_Name":properFirstName,"First_Name_Only":properFirstNameOnly,"Middle_Name":properMiddleName,"Last_Name":properLastName};
runUpdate = zoho.crm.updateRecord("Contacts",contact_id,updateInformation);
info runUpdate;