Field Rendering Using Numbers in Picklist

rslackrslack Member
edited February 5 in Problems

I am tracking office leases in Salesforce.  I have a picklist field called "Lease Term" that has the values 1 through 10.  Meaning it is a 1 year lease, 2 year lease, etc.  The information for each lease is listed in its specific year (see below.  I then Render the appropriate number of sections(years) based on the Lease Term so we only see pertinent data.   I do this using Lease_Term >= 3 (or whatever the total years would be.  This is working GREAT for the sections!

image

So now my problem...  Using the same logic I have a quick entry page that is always set to "edit" mode that allows me to quickly add in data for dates, base rents, and Triple Net information.  I only want the correct number of rows to show up on the quick entry section so I am using the same Lease_Term__c>=3 (or 4 or 5 etc) on each FIELD.  For Lease_Term picklist values between 1 and 9 this is working as expected.  In this picture I have selected 6 Years and the correct rows are showing up EXCEPT for the row that is set up as Lease_Term__c>=10. 

image

 The problem fields are "Date of 9th Increase", "Base Rent 9", "Triple Net 9".  These all have the render set up in the same way Lease_Term__c>=10.  (It is year 10 because there is a base year and then increases 1 through 9.  The first year there is no increase just a base rent.  I mention that just in case you were thinking Base rent 9 should be with picklist value 9).  See below for odd field render behavior.

image

Now what gets even more interesting is if I set Lease_Term__c to the value of 10 this is what happens.

image

All fields that have rendering on them disappear.  Again, their set up is Lease_Term>=4 (for example).  Which 10 is greater than 4 so it should still be showing.  

Keep in mind that my sections with the same logic are rendering perfectly.

image

Please let me know if I am overlooking something.  Thanks for all your help!  

I say it whenever possible, but I can't say it enough.  Thank you Skuid team for building a BEAUTIFUL tool that makes our lives so much easier.  Thank you for the phenomenal support and community too.  I can't thank you enough for all your help.  Skuid rocks!

Comments

  • Rob HatchRob Hatch Skuad, Sonar ✭✭
    edited September 2016
    Rich,  I think the problem is that picklist fields are really stored as text,  so when you try to use a "less than or equals to" operator you are going to get unexpected results.  Becuse its text the question "Is 10 greater than 4" is being evaluated as false.  So when 4 gets put in your picklist field - the fields on 10 are getting rendered.  I'm honestly not sure how the first example is working. 

      Have you ever tried to sort numbers that were really text?  I have this happen when sorting tables in MS Word.  When you sort by the number colum you get things like this. 

    1
    10
    11
    2
    3
    31
    32

    The same thing is happening here. 

    Here are a few work arounds. 

    1. Add a leading 0 to picklist values 1 - 9.   (OK - that's not really an option is it...)
    2. Change your conditional rendering so the 10 line only shows when the picklist value = 10.   Using a direct "=" condition makes sense because this is the only condition when you want the fields to show up (while in lines 9 - 1 there are more than one condition)
    3. Add a formula field to your object that takes the picklst field and turns it into a number.  The formula would look like this:   value(text(Picklist_Field))  .   Then do your rendering on the formula field. 


    Hope this helps... 

    On a side note.  I'm going to ask our devs why we even allow greater than and less than operators on picklst fields... That seems like its confusion just waiting to happen. 

  • rslackrslack Member
    edited February 5
    This makes perfect sense. Thank you for the quick reply! I just switched the field type to number only allowing 2 digits. And then I created a validation rule to make sure the number is always between 1 and 10. Works great! Thanks for the help Rob!
Sign In or Register to comment.