I wrote a code to update the Lettering of the first name in Zoho but it's not working

318 Views Asked by At

Here's the deluge script to capitalize the first letter of the sentence and make the other letters small that isn't working:

a = zoho.crm.getRecordById("Contacts",input.ID);

d = a.get("First_Name");

firstChar = d.subString(0,1);

otherChars = d.removeFirstOccurence(firstChar);

Name = firstChar.toUppercase() + otherChars.toLowerCase();

mp = map();

mp.put("First_Name",d);

b = zoho.crm.updateRecord("Contacts", Name,{"First_Name":"Name"});

info Name;

info b;

I tried capitalizing the first letter of the alphabet and make the other letters small. But it isn't working as expected.

5

There are 5 best solutions below

0
ZohoCoder On

Try removing the double-quotes from the Name value in the the following statement. The reason is that Name is your variable holding the case-adjusted name, but "Name" is the string "Name".

From:

b = zoho.crm.updateRecord("Contacts", Name,{"First_Name":"Name"});

To

b = zoho.crm.updateRecord("Contacts", Name,{"First_Name":Name});

0
silver On

Try using concat

Name = firstChar.toUppercase().concat( otherChars.toLowerCase() );
0
von-tastic On

This might help you

sentence = "salsalIn mOoKo sIge NA";
capitilize_first_char_every_word = sentence.proper();
capitilize_only_first_char_of_sentence = sentence.subString(0,1).toUpperCase().concat(sentence.subString(1,sentence.toList("").size()).toLowerCase());


info capitilize_first_char_every_word;
info capitilize_only_first_char_of_sentence;

Info result should be :

Salsalin Mooko Sige Na
Salsalin mooko sige na

You can try this script in https://dre.zoho.com/tryout

0
Jane On

Your code put 'd' into "First_Name" but 'd' wasn't cleansed. You also don't need a map as you are updating with the key/value in the update Record. Try this...

Set argument of contactId

contactRec = zoho.crm.getRecordById("Contacts",contactId);

firstChar = contactRec.get("First_Name").subString(0,1);

otherChars = contactRec.get("First_Name").removeFirstOccurence(firstChar);

firstName = firstChar.toUppercase() + otherChars.toLowerCase();

updateContact = zoho.crm.updateRecord("Contacts", contactId,{"First_Name":Name});
0
user22559850 On
a = zoho.crm.getRecordById("Contacts",cId);

d = a.get("First_Name");

firstChar = d.subString(0,1);

otherChars = d.removeFirstOccurence(firstChar);

Name = firstChar.toUppercase() + otherChars.toLowerCase();

mp = Map();

mp.put("First_Name",Name);

update = zoho.crm.updateRecord("Contacts", cId, mp);