How to add status field on module based on some condition?

I have use case where when I click on 'Activate' button ,an API is trigerred which will show an alert boc saying "Account is activated". 

Now , I want to add one field like below screen which will refelct the status of accounts. <<Ignore module name and other information it's just for reference>>

Please help me with some suggestions or any code snippet.

Parents
  • Hi Gautam,

    If you want something like below screenshot,

    Screenshot

    These are the steps you need to follow,

    1. Create a checkbox field named activated_c through studio.
    2. Make the field calculated and give formula as below,
      ifElse(equal($customerstatus_c,"Activated"), 1 , 0).
    3. The above formula will evaluate to 1 if customer status is Activated else 0.
    4. Download this file and extract it in custom/modules/<modulename>/clients/base/views/fields/.
    5. Now simply in record.php just add this few lines of code in fields array of panel header at last index.
      array(
                  'name' => 'panel_header',
                  'header' => true,
                  'fields' => array(
                      array(
                          'name' => 'picture',
                          'type' => 'avatar',
                          'size' => 'large',
                          'dismiss_label' => true,
                      ),
                      array(
                          'name' => 'name',
                          'type' => 'fullname',
                          'label' => 'LBL_NAME',
                          'dismiss_label' => true,
                      ),
                      array(
                          'type' => 'favorite',
                      ),
                      array(
                          'type' => 'follow',
                          'readonly' => true,
                      ),
                      array(
                          'name' => 'activated_c',
                          'type' => 'badge',
                          'dismiss_label' => true,
                          'readonly' => true,
                      ),
                  ),
              ),
    6. Now you will be able to see Activated label at top if the status is Activated else if the status if Other than Activated it will be shown as Not Activated.

    Hope this may help you.

    Vamshi S.

Reply
  • Hi Gautam,

    If you want something like below screenshot,

    Screenshot

    These are the steps you need to follow,

    1. Create a checkbox field named activated_c through studio.
    2. Make the field calculated and give formula as below,
      ifElse(equal($customerstatus_c,"Activated"), 1 , 0).
    3. The above formula will evaluate to 1 if customer status is Activated else 0.
    4. Download this file and extract it in custom/modules/<modulename>/clients/base/views/fields/.
    5. Now simply in record.php just add this few lines of code in fields array of panel header at last index.
      array(
                  'name' => 'panel_header',
                  'header' => true,
                  'fields' => array(
                      array(
                          'name' => 'picture',
                          'type' => 'avatar',
                          'size' => 'large',
                          'dismiss_label' => true,
                      ),
                      array(
                          'name' => 'name',
                          'type' => 'fullname',
                          'label' => 'LBL_NAME',
                          'dismiss_label' => true,
                      ),
                      array(
                          'type' => 'favorite',
                      ),
                      array(
                          'type' => 'follow',
                          'readonly' => true,
                      ),
                      array(
                          'name' => 'activated_c',
                          'type' => 'badge',
                          'dismiss_label' => true,
                          'readonly' => true,
                      ),
                  ),
              ),
    6. Now you will be able to see Activated label at top if the status is Activated else if the status if Other than Activated it will be shown as Not Activated.

    Hope this may help you.

    Vamshi S.

Children