Here's how to set a numeric field to null or to blank

Here's how to set a numeric field to null or to blank

I'm not sure this tip is discussed anywhere, so I thought I'd share it.

When a form has a numeric field, it initially is blank (assuming you have not given it a default value).  However at runtime, once you give it a value, you are not able to clear the field again.with a script unless you click the reset button or reload the form.  Unfortunately, that will clear all the fields in the form, not just the one field.

Although you can compare the value of a numeric field to null, you cannot assign a null to a numeric field.  The best you can do is give the field a zero value.

However, I found that you can clear a numeric field by doing the following:

input.NumericFieldName = null.toDecimal();
or
input.NumericFieldName = null.toLong();

BUT...
There is one catch!  Once you save the script, and reopen the script again, the line will look like this:

input.NumericFieldName = ;

As long as you don't save the script again, it will not be a problem.  But if you try to save the script, an error will be displayed.  You will need to go to that statement and retype the line again before saving the script.

I usually place a comment immediately above the statement to remind me what the original statement was if I need to edit the script again.  Something like this:

// input.NumericFieldName = null.toLong();
input.NumericFieldName = null.toLong();

Then when I edit the script again, it shows:

// input.NumericFieldName = null.toLong();
input.NumericFieldName = ;


Maybe Zoho can fix this so that the statement will remain so we won't have to retype the statement each time.






































    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方