Pages

Saturday, May 5, 2018

Salesforce: Picklist Default Value

Since Summer '17 release, Salesforce supports Default Value at the field level, this means we can define different default value based on the user, example: when front-end support creates a new case, Priority default value "high", while all other users will have the Priority default value to "low", although they can change it manually.

But, the field with picklist type will have its own default value, how this works with the default value introduced in Summer '17 release? In summary, it can be up to 3 places for a picklist field to have a default value defined.

Below is a simple logic on how this works, I would agree it would be easier to read this in a flowchart.

If Default Value in General Options (field level) is defined
    if Record Type* for the object is defined
        if Formula General Option resolve** to an active item & available in Record Type
            --> use resolve Value from General Options
        else if there is Default Value selected in Record Type
            --> use selected Default Value in Record Type
        else
            --> no default value
        endif
    else
        if Formula General Option resolve** to an active item
            --> use resolve Value from General Options
        else if there is Default Value selected in Field Picklist
            --> use selected Default Value in Field Picklist
        else
            --> no default value
        endif
    endif
else
    if Record Type for the object is defined
        if there is Default Value selected in Record Type
            --> use selected Default Value in Record Type
        else if there is Default Value selected in Field Picklist
            --> use selected Default Value in Field Picklist
        else
            --> no default value
        endif
    else
        if there is Default Value selected in Field Picklist
            --> use selected Default Value in Field Picklist
        else
            --> no default value
        endif
endif

* even there is only 1 record type defined and active
** the formula resolved is case-sensitive with the item API name

Note: from the above logic, the default value from the field level is processed first, if no or fail fit to API name, check if any record type and the default value, and the last would be the default value in the picklist. 
The default value in record type is treated at the same level as the default value from the picklist, therefore, for an object with record type, if there is no default value defined, the system will not check further if any default value selected in the picklist field.


Here a few samples:
there is no default value defined at the field level, all user will get the default value from the selected item


The default value in the field resolved as High1, while the picklist API name is High, the default value from the field level will not apply - it is case-sensitive too.


Reference:




No comments:

Post a Comment