23

Scenario:

I have a lightning component for my Save and Submit buttons. I thought I will need to add a design attribute and made the following changes:

Design

<design:component>
    <design:attribute name="taxRate" label="Tax Rate in %"/>
    ....
</design:component>

Component

<aura:component controller="FormController" implements="flexipage:availableForAllPageTypes,force:appHostable" access="global">
    <aura:attribute name="taxRate" type="String" access="global"/>
    ....
</aura:component>

After applying these changes, I found another method that renders this attribute useless. In the process of reverting the aforementioned changes returns the following error:

Failed to save undefined: Cannot remove design attributes when the component implements a Lightning Page interface.: Source

Problem:

How do I remove a design:attribute and it's corresponding aura:attribute?

Attempted fixes:

I tried to follow the tips in this link: Tips and Considerations for Configuring Components for Lightning App Builder

Also tried removing the component from the lightning apps before trying again without success.

4 Answers 4

35

This is a bit tricky Exercise .In fact the error gives an idea on why this showing up .When you have implemented a lightning Interface of AllPageTypes which means you cannot get rid of design file attributes

Step 0 - you might have to delete Lightning Pages that make reference to the component. Otherwise Salesforce might show an error when you try to remove the interface (or fields).

Step 1 - Lets remove the Interface from your code first ,so try removing the implements attribute

     <aura:component controller="FormController" access="global">
     <aura:attribute name="taxRate" type="String" access="global"/>
     ....
          </aura:component>

Step 2 - Remove the Design attribute now .

Step 3 - Remove the Attribute once you have removed the designed reference

Step 4 - Add the implements and other code back .

3
  • Thanks @Mohith, following your steps led me to solve the problem. I see now that the implements attribute was preventing me from removing the <design:attribute>. These are the steps I performed: 1. Remove use of the involved Lightning Component from all Lightning Page using Lightning App Builder 2. CMP file - cut the implements="xxx" attribute, then Save. 3. DESIGN file - remove the <design:attribute>, then Save. 4. CMP file - remove the <aura:attribute>, restore the implements="xxx" attribute, then Save. 5. Restore Lightning Component back to all affected Lightning Apps.
    – Bryan
    Commented Jul 21, 2016 at 18:23
  • Important Note: for Step 1 to work, you might have to delete Lightning Pages that make reference to the component Commented Jan 26, 2018 at 19:00
  • 1
    In my case, I was able to avoid Step 0 by removing the component reference out of the XML of the flexipage that contained the component. This was after 1) removing the component from page in the Experience Builder AND publishing the change then 2) deleting the component from the org. The reference for the component in the .flexipage XML was still there. Removing the XML branch containing the definition of my component, deploying that .flexipage file, THEN fixing my Aura component, redeploy (successfully), and re-add the component with its old properties (manually) work. YMMV.
    – jschrab
    Commented Mar 23, 2020 at 15:50
22

I had this issue and the following worked for me:

  1. Delete the design file
5
  • 2
    God damn salesforce duckery, thank you this worked. Commented May 28, 2019 at 18:30
  • LOL Very nice solution but someone needs to open a consulting shop based solely on SDFD Quirky dev workarounds. Would add a few years on all of our lives.. Who's on first.. what's on second.. :)
    – ChiCloud
    Commented Nov 7, 2019 at 1:30
  • 1
    Couldn't help but laugh at the facerolling simplicity of the answer compared to the accepted solution. Commented Oct 25, 2020 at 11:08
  • @thoriyas or anyone else - Were you able to delete the design file from dev-console in Production?
    – Cloud Man
    Commented May 7, 2021 at 16:37
  • very smart solution, just deleted the design file from dev console and able to upload the updated file from vs code, thank you. My component was referred in 100s of pages including multiple exp. sites, thank you for saving the hours. Commented Nov 17, 2022 at 23:49
8

For the record, these are the specific steps I performed to solve the problem after following @Mohith answer:

  1. Remove use of the involved Lightning Component from all Lightning Page using Lightning App Builder.

    • Note: Performing step 2 first can be helpful in identifying which Lightning Pages are using the Lightning Component
    • Alert: Take note of the involved Lightning Component's attribute values before removing from the Lightning Page. Unless these are the default values defined in the CMP file's <aura:attribute>, there's no way to restore this once Lightning App Builder is done saving.
  2. CMP file - cut the implements="xxx" attribute, then Save.

  3. DESIGN file - remove the <design:attribute>, then Save.
  4. CMP file - remove the <aura:attribute>, restore the implements="xxx" attribute, then Save.
  5. Restore Lightning Component back to all affected Lightning Apps and re-populate the attributes.
1
  • Works for me!!! Commented Jun 19, 2017 at 13:43
2

As for my case, all the answer didn't worked for me. Here is my workaround:

  1. Open Developer Console -> then open *.design file.
  2. From Menu: File -> Delete (CTRL + DELETE) to delete the file.
  3. Create new design file with the same name in Visual Studio Code, then deploy.

You have to do these again if you want to remove attribute from design file

1
  • were you able to do this step-2 in production?
    – Cloud Man
    Commented May 7, 2021 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .