Pages

Sunday, September 4, 2016

Salesforce: Rename Field Name

Earlier blog, we discussed about what happened when we try to delete a field used in business rules, in most cases Salesforce will smart enough to detect this and stop you from delete the field.

But, how about to rename field name? From times to times, because of business changes or something else, you get request to change the field label? Change Field Label should be no issue at all, but how about if you are type of admin that looking for perfection, Field Name (API Name) should be also change and follow Field Label? Should you also change the Field Name (API Name) ?

Personally, I would like to have API Name similar to Field Label, but sometimes, for many reason it would be risky to change this, mostly if the field has been deployed in production, or close to deployment date.

Let's see what happened when we change API Name, and how Salesforce re-act with this. This blog is written with Summer 16 release, so it may change / fix in the future.

1. Validation Rule 
Active & Inactive Validation Rule - Auto Update and No issue

2. Custom Formula Field 
Auto Update and No issue

3. Workflow Rule (include Approval Process)
  * as dropdown / criteria are met - Active or Inactive - Auto Update and No issue
  * as formula evaluates to true - Active or Inactive - Auto Update and No issue

4. Field Updates action for Workflow Rule
Auto Update and No issue

5. Email Template
Auto Update and No issue

6. Apex Trigger 
Not Allowed

7. Apex Class 
Not Allowed

8. Process Builder (as condition / dropdown)
  * use as Criteria - Auto Update and No issue
  * use as Filter in Record update - NO API field name auto update, "Error Occurred During Flow"
  * use as Field Values in Record update - NO API field name auto update, "Error Occurred During Flow"

9. Process Builder (as formula)
  * use as Criteria - NO API field name auto update, no error on data update, process not trigger

10. Flow 
API field name auto update, "Error Occurred During Flow"

For Process Builder and Flow, when error occurred, user who create the Process Builder or Flow will get email address, sample:

This error happened in Process Builder, when it cannot find the field name in Decision
An error occurred at element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Field_Name__c because it hasn't been set or assigned.

Flow Details
Flow Name: Name
Type: Workflow
Version: 1
Status: Active


This error happened in Flow, when it cannot find the field name for record update
An error occurred at element myRule_1_Name (FlowRecordUpdate).
unable to parse field as dataType could not be retrieved for the passed field: RawFieldImpl[tableName: Account, columnName: Field_Name__c]

Flow Details
Flow Name: Name
Type: Autolaunched Flow
Version: 1
Status: Active


This error happened in Process Builder, when call Flow failed
An error occurred at element myRule_1_Name (FlowActionCall).
An error occurred when executing a flow interview. 

Flow Details
Flow Name: Name
Type: Workflow
Version: 1
Status: Active

From the email received, you can investigate where it failed, and what is the caused.

In summary: validation rule, workflow and email template will auto update the API name for you, apex class and trigger will block you from change the field name, while Process Builder and Flow will throw run-time error and it is ugly.

If your user double click the field to update, they will get the red error message:
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30150000000LJyG. Contact your administrator for help.




If your user click Edit button and Save, they will get following screen below, which actually have the same message:



While user who create the Process or Flow will get error email from "Flow Application" with body as mentioned above. Read this blog Validation Rule in Workflow and Process Builder on how to trace what is 301xxxxx error message when your user report this error.



Reference:


No comments:

Post a Comment